Wrong Point Cloud

asked 2017-03-06 09:47:00 -0500

mirnyy gravatar image

updated 2017-03-09 06:15:22 -0500

Hello, i used two images from the same calibrated camera two obtain a point cloud.

First i rectified these images. The result is looking quite good.

Then i caluclated a disparity map from the 2 rectified images. The result is looking quite good.

Then i tried to calculate the point cloud using the reprojectImageTo3d()-function and a self-constructed reprojection matrix Q, but the result is looking bad now.

My code snippet to calculate the point cloud is the following:

Mat XYZ(image_disparity.size(), CV_32FC3);

Q = (Mat_<double>(4, 4) <<  1, 0, 0, -1520.69,
                            0, 1, 0, -1006.81,
                            0, 0, 0, -2759.48,
                            0, 0, 1, 0);

reprojectImageTo3D(image_disparity, XYZ, Q);

All the images of the workflow are here:

edit retag flag offensive close merge delete


yea, that's admittedly terrible hard to get right. even with the correct Q matrix, it would only look ok from a certain viewpoint.

if you're just curious, how good disparity is, - maybe try to use (x,y,disparity/16) instead of reprojectImageTo3D(). it'll give you a "cube" , not a "pyramid" view, but imho, it's sometimes better this way.

berak gravatar imageberak ( 2017-03-06 10:52:04 -0500 )edit

oh, btw, did the "other" formula from the opencv3 book fare any better ?

berak gravatar imageberak ( 2017-03-06 10:55:34 -0500 )edit

I'm facing same problem. Epipolar line are wrong and disparity is bad...and my camera are basic webcam then color are differents

LBerger gravatar imageLBerger ( 2017-03-06 11:13:32 -0500 )edit

@berak: you can see the results at my link :D The formula is used is kind of the combination from your link and the opencv3 book.

@LBerger: Did you rectify both images? it doesn't look so...

mirnyy gravatar imagemirnyy ( 2017-03-06 11:20:30 -0500 )edit

@mirnyy Oops I forgot I have updated video (just press w in program)

LBerger gravatar imageLBerger ( 2017-03-06 11:29:33 -0500 )edit

What program do you mean?

mirnyy gravatar imagemirnyy ( 2017-03-06 11:30:36 -0500 )edit

@LBerger: That looks like a really messy disparity map.

@mirnyy: What's your z scale? It looks like the z is very exaggerated. I can't really tell for certain though.

Tetragramm gravatar imageTetragramm ( 2017-03-06 17:41:18 -0500 )edit

@Tetragramm I'm agree. I think that image are not well rectified algorithm cannot find good disparities

LBerger gravatar imageLBerger ( 2017-03-07 11:52:34 -0500 )edit

@Tetragramm: What do you mean with "z scale"? I just used the Matrix Q like i wrote in my post...

mirnyy gravatar imagemirnyy ( 2017-03-07 13:04:24 -0500 )edit