FindStereoCorrespondence
Calculates disparity for stereo-pair
cvFindStereoCorrespondence(
const CvArr* leftImage, const CvArr* rightImage,
int mode, CvArr* depthImage,
int maxDisparity,
double param1, double param2, double param3,
double param4, double param5 );
leftImage
Left image of stereo pair, rectified grayscale 8-bit image
rightImage
Right image of stereo pair, rectified grayscale 8-bit image
mode
Algorithm used to find a disparity (now only CV_DISPARITY_BIRCHFIELD is supported)
depthImage
Destination depth image, grayscale 8-bit image that codes the scaled disparity, so that the zero disparity (corresponding to the points that are very far from the cameras) maps to 0, maximum disparity maps to 255.
maxDisparity
Maximum possible disparity. The closer the objects to the cameras, the larger value should be specified here. Too big values slow down the process significantly.
param1, param2, param3, param4, param5
- parameters of algorithm. For example, param1 is the constant occlusion penalty, param2 is the constant match reward, param3 defines a highly reliable region (set of contiguous pixels whose reliability is at least param3), param4 defines a moderately reliable region, param5 defines a slightly reliable region. If some parameter is omitted default value is used. In Birchfield's algorithm param1 = 25, param2 = 5, param3 = 12, param4 = 15, param5 = 25 (These values have been taken from "Depth Discontinuities by Pixel-to-Pixel Stereo" Stanford University Technical Report STAN-CS-TR-96-1573, July 1996.)
The function cvFindStereoCorrespondence calculates disparity map for two rectified grayscale images.
Example. Calculating disparity for pair of 8-bit color images
/*---------------------------------------------------------------------------------*/
IplImage* srcLeft = cvLoadImage("left.jpg",1);
IplImage* srcRight = cvLoadImage("right.jpg",1);
IplImage* leftImage = cvCreateImage(cvGetSize(srcLeft), IPL_DEPTH_8U, 1);
IplImage* rightImage = cvCreateImage(cvGetSize(srcRight), IPL_DEPTH_8U, 1);
IplImage* depthImage = cvCreateImage(cvGetSize(srcRight), IPL_DEPTH_8U, 1);
cvCvtColor(srcLeft, leftImage, CV_BGR2GRAY);
cvCvtColor(srcRight, rightImage, CV_BGR2GRAY);
cvFindStereoCorrespondence( leftImage, rightImage, CV_DISPARITY_BIRCHFIELD, depthImage, 50, 15, 3, 6, 8, 15 );
/*---------------------------------------------------------------------------------*/
And here is the example stereo pair that can be used to test the example
Partager