Ask Your Question
0

How do I calculate disparity and pointcloud

asked 2017-05-11 10:06:15 -0600

hagor gravatar image

Hello. I tried different ways to calculate disparity map, but can't get a good result. my images: can be found here: http://imgur.com/ViixWKN http://imgur.com/8NrA61K my calibration : https://pastebin.com/LY73x9NA

Unfortunatelly I can't get a good point cloud, with my code : https://pastebin.com/xT7KXVig

Maybe my calibration is not good enough, or the angle between cameras is too small. If my focal length is 35 mm and pixel size 5.5 x 5.5 μm2 , so the focal length should be around 6363 and i get 6700, which means that my lens is not exactly 35mm, but still I hope that my calibration is correct. rms error is 0.9.

During the calibration I use "chessboard rectangle size" what does it influence on? It seems that my calibration is the same, if I use rectangleSize 0.032 or 32.

Do I need to dothe following code?

    Mat img1r, img2r;
    remap(img1, img1r, map11, map12, INTER_LINEAR);
    remap(img2, img2r, map21, map22, INTER_LINEAR);
    img1 = img1r;
    img2 = img2r;

It seems that it kills all the disparity.

Do I need to normalize the disparity map?

How does stereoRectify influence my pre calibrated system? was looking at this problem http://answers.opencv.org/question/60..., but still can't get a good point cloud.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2017-05-11 10:51:04 -0600

Laurentiu gravatar image

Maybe here you found the theory for camera calibration and code: http://docs.opencv.org/3.1.0/d4/d94/t...

and here is code for compute disparity map using sgbm algorithm in c++ with OpenCv

http://stackoverflow.com/questions/35...

edit flag offensive delete link more

Comments

Did, as they suggested at the example, but still my point cloud looks like a plane. How does the pixel number influence the disparity map? If i have 4k image, does that mean, that I have to increase threshholds?

hagor gravatar imagehagor ( 2017-05-15 06:44:17 -0600 )edit
0

answered 2017-05-11 11:31:42 -0600

LBerger gravatar image

You have an example [here]https://github.com/opencv/opencv/blob/master/samples/cpp/stereo_calib.cpp) about stereocalibration and here about stereo algorithm. Some tutorials about calibration :

1

2

3

"Do I need to normalize the disparity map?" No It will change unit. Now if you use stereobm or stereosgbmwith default parameter disparity is coded in CV_16S (short). But 17 in disparity map means 17/16 of pixel. You ghave to divide disparyt map by 16 before using reprojectImageTo3D

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-05-11 10:06:15 -0600

Seen: 2,297 times

Last updated: May 11 '17