Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void) computeStereoVarMapWithImageLeft:(CGImageRef)leftImage
- imageRight:(CGImageRef)rightImage
- minDisparities:(NSUInteger)minDisparities
- maxDisparities:(NSUInteger)maxDisparities
- iterations:(NSUInteger)iterations
- polyN:(NSUInteger)polyN
- polySigma:(double)polySigma
- fi:(double)fi
- lambda:(double)lambda
- {
- /**
- * Convert the CGImageRef to cv::Mat
- */
- cv::Mat left = [self CVMatWithCGImage:leftImage];
- cv::Mat right = [self CVMatWithCGImage:rightImage];
- /**
- * Initialization of cv::StereoVar
- */
- cv::StereoVar var;
- // Hard-coded
- var.levels = 3;
- var.pyrScale = 0.25;
- /**
- * Stereo Variation parameters
- */
- var.nIt = (int)iterations;
- var.minDisp = -(int)minDisparities;
- var.maxDisp = (int)maxDisparities;
- var.poly_n = (int)polyN;
- var.poly_sigma = polySigma;
- var.fi = fi;
- var.lambda = lambda;
- var.penalization = cv::StereoVar::PENALIZATION_TICHONOV;
- var.cycle = cv::StereoVar::CYCLE_V;
- var.flags = cv::StereoVar::USE_SMART_ID | cv::StereoVar::USE_MEDIAN_FILTERING;
- /**
- * Need to downscale the original images to get a decent framerate.
- */
- cv::resize(left, left, cv::Size(), 0.25, 0.25, cv::INTER_CUBIC);
- cv::resize(right, right, cv::Size(), 0.25, 0.25, cv::INTER_CUBIC);
- /**
- * Initialize the disparity map cv::Mat.
- */
- cv::Mat disparity8 = cv::Mat(left.rows, left.cols, CV_8UC1);
- /**
- * Compute the disparity map.
- */
- var(left, right, disparity8);
- /**
- * Upscale the resulting disparity map.
- */
- cv::resize(disparity8, disparity8, cv::Size(640, 480), 0, 0, cv::INTER_CUBIC);
- /**
- * Convert it to CGImageRef in order to be able to get a QC provider from the plug-ins.
- */
- _disparityImage = [self CGImageRefWith:disparity8];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement