简体   繁体   English

立体声矫正-ROI具有不同大小

[英]Stereo rectify - ROI have different sizes

I have done a stereo calibration and I got the validPixROI1 and 2 (green border). 我已经完成了立体声校准,并且得到了validPixROI1和2(绿色边框)。 Now I want to use StereoSGBM but the rois from calibration (from stereoRectify) are not the same size. 现在,我想使用StereoSGBM,但是校准(来自stereoRectify)的rois大小不一样。 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,那么之后可以使用这些ROI掩盖结果的无效位...

   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. 在光轴和像平面相交处的点R。 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. 在其中一个示例中,对于640x480像素相机,主要点是302.71656,242.33386,这表明主要点和图像中心不同。

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. 该调用返回一个cv :: Rect,它将成为左侧图像和视差图中所有有效像素的边界框。 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. 请注意,从stereoRectify返回的ROI仅是从照相机内部函数重映射之后的有效像素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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