Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

stereoRectify problems

Hi. I'm working with SFM results. I've calculated orientation params for each camera, undistorted images and selected some stereopairs. Now I would like to calculate rectification for each stereopair.

left and right images: image description

image description

At first rotatation between camera 1 & 2 using quaternion approach: rot_q = q2*q1.inverse();

translation T = C2 - C1, where Cx - camera centers.

Then

stereoRectify(K1, D, K2, D, img1.size(), R12, T, OR1, OR2, OP1, OP2, OQ, 0);

where Kx - camera matrix & D - distortion vector with zero values. and

initUndistortRectifyMap(K1, D, OR1, OP1, img1.size(), CV_32FC1, MX1, MY1); initUndistortRectifyMap(K2, D, OR2, OP2, img2.size(), CV_32FC1, MX2, MY2);

and in conclusion

remap(img1, rect_img_left, MX1, MY1, INTER_CUBIC); remap(img2, rect_img_right, MX2, MY2, INTER_CUBIC);

But result seems to be not absolutely correct

image description

So it was cropped as you can see

image description image description

and an Y shift between corresponding epipolines approx 5 pixels

Also, I've tried to build rectification using fundamental matrix & stereoRectifyUncalibrated, because I know corresponding points between images. For this scene it works fine image description

But for some projects (uav images for example) I've got heavy distortions after warping and in general it must be more correctly to use the first approach. Any ideas?

stereoRectify problems

Hi. I'm working with SFM results. I've calculated orientation params for each camera, undistorted images and selected some stereopairs. Now I would like to calculate rectification for each stereopair.

left and right images: image description

image descriptionimage description

image description

At first rotatation between camera 1 & 2 using quaternion approach: rot_q = q2*q1.inverse();

translation T = C2 - C1, where Cx - camera centers.

Then

stereoRectify(K1, D, K2, D, img1.size(), R12, T, OR1, OR2, OP1, OP2, OQ, 0);

where Kx - camera matrix & D - distortion vector with zero values. and

initUndistortRectifyMap(K1, D, OR1, OP1, img1.size(), CV_32FC1, MX1, MY1); initUndistortRectifyMap(K2, D, OR2, OP2, img2.size(), CV_32FC1, MX2, MY2);

and in conclusion

remap(img1, rect_img_left, MX1, MY1, INTER_CUBIC); remap(img2, rect_img_right, MX2, MY2, INTER_CUBIC);

But result seems to be not absolutely correct

image description

So it was cropped as you can see

image description image description

and an Y shift between corresponding epipolines approx 5 pixels

Also, I've tried to build rectification using fundamental matrix & stereoRectifyUncalibrated, because I know corresponding points between images. For this scene it works fine image description

But for some projects (uav images for example) I've got heavy distortions after warping and in general it must be more correctly to use the first approach. Any ideas?

stereoRectify problems

Hi. I'm working with SFM results. I've calculated orientation params for each camera, undistorted images and selected some stereopairs. Now I would like to calculate rectification for each stereopair.

left and right images: image description

image description

At first rotatation between camera 1 & 2 using quaternion approach: rot_q = q2*q1.inverse();

translation T = C2 - C1, where Cx - camera centers.

Then

stereoRectify(K1, D, K2, D, img1.size(), R12, T, OR1, OR2, OP1, OP2, OQ, 0);

where Kx - camera matrix & D - distortion vector with zero values. and

initUndistortRectifyMap(K1, D, OR1, OP1, img1.size(), CV_32FC1, MX1, MY1); initUndistortRectifyMap(K2, D, OR2, OP2, img2.size(), CV_32FC1, MX2, MY2);

and in conclusion

remap(img1, rect_img_left, MX1, MY1, INTER_CUBIC); remap(img2, rect_img_right, MX2, MY2, INTER_CUBIC);

But result seems to be not absolutely correct

image descriptionimage description

So it was cropped as you can see

image description image descriptionimage description image description

and an Y shift between corresponding epipolines approx 5 pixels

Also, I've tried to build rectification using fundamental matrix & stereoRectifyUncalibrated, because I know corresponding points between images. For this scene it works fine image descriptionimage description

But for some projects (uav images for example) I've got heavy distortions after warping and in general it must be more correctly to use the first approach. Any ideas?

stereoRectify problems

Hi. I'm working with SFM results. I've calculated orientation params for each camera, undistorted images and selected some stereopairs. Now I would like to calculate rectification for each stereopair.

left and right images: image description

image descriptionimage description

image description

At first rotatation between camera 1 & 2 using quaternion approach: rot_q = q2*q1.inverse();

translation T = C2 - C1, where Cx - camera centers.

Then

stereoRectify(K1, D, K2, D, img1.size(), R12, T, OR1, OR2, OP1, OP2, OQ, 0);

where Kx - camera matrix & D - distortion vector with zero values. and

initUndistortRectifyMap(K1, D, OR1, OP1, img1.size(), CV_32FC1, MX1, MY1); initUndistortRectifyMap(K2, D, OR2, OP2, img2.size(), CV_32FC1, MX2, MY2);

and in conclusion

remap(img1, rect_img_left, MX1, MY1, INTER_CUBIC); remap(img2, rect_img_right, MX2, MY2, INTER_CUBIC);

But result seems to be not absolutely correct

image descriptionimage description

So it was cropped as you can see

image description image descriptionimage description image description

and an Y shift between corresponding epipolines approx 5 pixels

Also, I've tried to build rectification using fundamental matrix & stereoRectifyUncalibrated, because I know corresponding points between images. For this scene it works fine image descriptionimage description

But for some projects (uav images for example) I've got heavy distortions after warping and in general it must be more correctly to use the first approach. Any ideas?

stereoRectify problems

Hi. I'm working with SFM results. I've calculated orientation params for each camera, undistorted images and selected some stereopairs. Now I would like to calculate rectification for each stereopair.

left and right images: image description

image description

At first rotatation between camera 1 & 2 using quaternion approach: rot_q = q2*q1.inverse();

translation T = C2 - C1, where Cx - camera centers.

Then

stereoRectify(K1, D, K2, D, img1.size(), R12, T, OR1, OR2, OP1, OP2, OQ, 0);

where Kx - camera matrix & D - distortion vector with zero values. and

initUndistortRectifyMap(K1, D, OR1, OP1, img1.size(), CV_32FC1, MX1, MY1); initUndistortRectifyMap(K2, D, OR2, OP2, img2.size(), CV_32FC1, MX2, MY2);

and in conclusion

remap(img1, rect_img_left, MX1, MY1, INTER_CUBIC); remap(img2, rect_img_right, MX2, MY2, INTER_CUBIC);

But result seems to be not absolutely correct

image description

So it was cropped as you can see

image description image description

and an Y shift between corresponding epipolines approx 5 pixels

Also, I've tried to build rectification using fundamental matrix & stereoRectifyUncalibrated, because I know corresponding points between images. For this scene it works fine image description

But for some projects (uav images for example) I've got heavy distortions after warping and in general it must be more correctly to use the first approach. Any ideas?

Upd. Input matrices by the link https://www.dropbox.com/s/aryl0k5j4o0uz2g/mat.yml?dl=0