Ask Your Question
1

Stereorectify ROI Valid?

asked 2014-03-13 13:55:39 -0600

pziyang gravatar image

updated 2014-03-13 14:37:35 -0600

I'm doing a stereovision setup. With 2 cameras mounted above a wing. The left camera is tilted a few degree inwards while the right camera in parallel with the wing.

Image of left and right view are here image description

So i performed stereocalibration using the following code. The reprojection error returned by cv::stereocalibrate is 0.6044. (note: snippets of code, cut and pasted, but does not compile as is)

// performing stereocalibration given imagePoint_leftcamera and rightcamera
Flea3.reproj_error = stereoCalibrate(objectPoints,imagePoints_left,imagePoints_right,cameraMatrix_left,
        distCoeffs_left,cameraMatrix_right,distCoeffs_right,imageSize, Flea3.R, Flea3.T, Flea3.E, Flea3.F,
        TermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, 1e-5),
        CV_CALIB_FIX_INTRINSIC );

// Peform stereorectification
stereoRectify(cameraMatrix_left, distCoeffs_left, cameraMatrix_right, distCoeffs_right, imageSize, Flea3.R, Flea3.T, Flea3.R1, Flea3.R2, Flea3.P1, Flea3.P2, Flea3.Q, CALIB_ZERO_DISPARITY, -1, Size(), &Flea3.validRoi_left, &Flea3.validRoi_right);

The remapped images using

//computes undistort and rectify maps
initUndistortRectifyMap(cameraMatrix_left, distCoeffs_left, R1, P1, imageSize, CV_16SC2, rmap[0][0], rmap[0][1]);
initUndistortRectifyMap(cameraMatrix_right, distCoeffs_right, R2, P2, imageSize, CV_16SC2, rmap[1][0], rmap[1][1]);

and

remap(src_left, img_left, rmap[0][0], rmap[0][1], CV_INTER_LINEAR);
remap(src_right, img_right, rmap[1][0], rmap[1][1], CV_INTER_LINEAR);

are here

image description

Question: Shouldn't the black remapped region from the right image be on the right side (since we're forming a frontal parallel configuration in stereorectify?

Also, the ROI regions returned is strange, denoted by red box here in the stitched image image description

The ROI region is clearly incorrect, but the stereorectified image seems good.

Question: Why is this so?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-03-31 04:38:31 -0600

flankechen gravatar image

It seems that the ROI is not defined in top-left+width,height but chopping from the margin.

I got ROIs like:

    %YAML:1.0
validRoi1: !!opencv-matrix
   rows: 1
   cols: 4
   dt: i
   data: [ 60, 40, 36, 59 ]
validRoi2: !!opencv-matrix
   rows: 1
   cols: 4
   dt: i
   data: [ 14, 55, 45, 1 ]

and the max of data[0-3] referring left,top, right,bottom chopping pixels.

I have a 640*480 retify image and line(retify,Point(60,55),Point(480-45,640-59),Scalar(0,255,0),1); goes through the ROI successfully.

If these helps, please share what you see and why this ROI is not top-left+width,height like other opencv roi. I have seem others stereoRectify() out the top-left+width,height roi.

Strange.......

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-13 13:55:39 -0600

Seen: 2,534 times

Last updated: Mar 31 '14