ios获取左右眼图片景深图

    cv::Mat leftMat,rightMat,depthMapMat;
    UIImageToMat(leftImage, leftMat);
    UIImageToMat(rightImage, rightMat);
    if (leftMat.type()>0) {
        cv::cvtColor(leftMat,leftMat,cv::COLOR_RGB2GRAY);
    }
    if (rightMat.type()>0) {
          cv::cvtColor(rightMat,rightMat,cv::COLOR_RGB2GRAY);
    }
    //int numDisparities = 0, int blockSize = 21
    cv::Ptr<cv::StereoBM> sbm = cv::StereoBM::create(32,21);
    sbm->compute(leftMat, rightMat, depthMapMat);
    depthMapMat.convertTo(depthMapMat,CV_8UC1);


    UIImage *depthMapImage=MatToUIImage(depthMapMat);
    leftMat.release();
    rightMat.release();
    depthMapMat.release();
 
posted @ 2015-08-25 16:04 Ethan_村长 阅读(...) 评论(...) 编辑 收藏