简体   繁体   中英

Stereo rectify - ROI have different sizes

I have done a stereo calibration and I got the validPixROI1 and 2 (green border). Now I want to use StereoSGBM but the rois from calibration (from stereoRectify) are not the same size. Anyone know how to solve this?

Actually I do somethine linke this:

Rect roiLeft(...);
Rect roiRight(...);

Mat cLeft(rLeft, roiLeft);
//Mat cRight(rRight, roiRight); // not same size...
Mat cRight(cRight, roiLeft);

stereoBM(cLeft,cRight, dst);

If I crop my images with that roi, will be the picture middle point be the same?

Here it works.

在此处输入图片说明

Why not run stereoBM on the (uncropped)calibrated images, then you can use those ROIs after to mask out the invalid bits of the result...

   stereoBM(rLeft,rRight, disp);
   //get intersection of both rois or use target image roi, if you know the target image
   cv::Rect visibleRoi = roiLeft & roiRight;
   cv::Mat cDisp(disp,visibleRoi);

Now you have no issues with different size inputs, or different centers and such.

Cheers

According to wiki

A point R at the intersection of the optical axis and the image plane. This point is referred to as the principal point or image center.

So I don't think the center will be same. Refer to this site . Here in one of the examples the principal point is 302.71656,242.33386 for a 640x480 pixel camera which shows that the principal point and the image center are not the same.

Run the block matcher on the uncropped rectified images and then use.

cv::getValidDisparityROI(roi1, roi2, minDisparity, numberOfDisparities, SADWindowSize);

That call returns a cv::Rect that will be a bounding box for all the valid pixels in the left image and the disparity map. The valid pixels are only pixels that both cameras can "see" (caveat on occluded edges).

Once you have the disparity map the right image becomes useless.

Be aware that the roi's returned from stereoRectify are just valid pixels after the remap from the cameras intrinsics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM