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();