Ask Your Question
0

Depth from Disparity

asked 2017-03-06 05:00:38 -0600

mirnyy gravatar image

updated 2017-03-06 05:50:18 -0600

Hello,

i have 2 images from the same calibrated camera. I could rectify the images using the following snippet:

Mat H1, H2; 
stereoRectifyUncalibrated(image_points[0], image_points[1], F, image1.size(), H1, H2);

warpPerspective(image1, image1_rectified, H1, image1.size());
warpPerspective(image2, image2_rectified, H2, image2.size());

image_points[0] and image_points[1] are the corresponding image points from image1 and image2 (calculated with SURF and then matched).

I also can calculate the disparity map with the two rectified images using StereoSGBM.

The next and last step would be to use

reprojectImageTo3D(image_disparity, XYZ, Q);

but i don't have the reprejection matrix Q.

Can someone describe me how to obtain this parameter?
I have the intrinsic camera matrix.

edit retag flag offensive close merge delete

Comments

just to clarify:

i have 2 images from a calibrated camera.

that is, 2 images from the same camera ?

berak gravatar imageberak ( 2017-03-06 05:41:54 -0600 )edit

yes, it is

mirnyy gravatar imagemirnyy ( 2017-03-06 05:49:48 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-06 06:02:39 -0600

berak gravatar image

with a stereo cam setup, you would use stereoRectify() which would also return the Q matrix

lacking that, you could still try to build a synthetic Q mat (you can extract f from your camera intrinsic Mat)

edit flag offensive delete link more

Comments

1

Why i can't use stereoRectify() with my single camera setup? I mean it's like a stereo cam setup, just with the same camera. I just need to know the R, and t parameter for this funtion.

The Q mat what you linked looks a bit different than the one in the book "Learning OpenCV 3". There it says the Q mat looks like:

Q = [1, 0, 0,     -cx;
     0, 1, 0,     -cy;
     0, 0, 0,      f;
     0, 0, -1/Tx, (cx-c'x)/Tx]
mirnyy gravatar imagemirnyy ( 2017-03-06 06:16:09 -0600 )edit

what is Tx ?

berak gravatar imageberak ( 2017-03-06 06:34:31 -0600 )edit

probably the "position" of the "first" camera

mirnyy gravatar imagemirnyy ( 2017-03-06 06:37:29 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-06 05:00:38 -0600

Seen: 1,290 times

Last updated: Mar 06 '17