opencvimage-processingcamera-calibrationstereoscopy

OpenCV - Metric representation in `reprojectImageTo3D()`


On my left camera, right camera and stereo calibration; I've indicated the size of the square

0.025 (25 millimeters)

So I get the points in 3D using reprojectImageTo3D(disp, Q)

disp = stereo.compute(dstL, dstR).astype(np.float32) / 16.0
disp = abs(disp-min_disp)/num_disp

I got Q from stereoRectify

I took a picture of a box 2.5 - 3 ft away from the stereo camera and retrieved the xyz coordinates of a point lying on it. Its Z value is 140.8764

How should I interpret that?

My Q looks like this

|1, 0, 0, -454.05216408|
|0, 1, 0, -231.55072975|
|0, 0, 0, 816.20826814 |
|0, 0, 13.79730561, -0 |

Solution

  • Having used units consistently within all respective calibration functions (in this case metres), then the output from cv::reprojectImageTo3D should have similar units (here again metres).

    In Q, the value at (3,2) is the inverse of the camera baseline value (here 0.0725 m which makes sense). Values at (0,3) and (1,3) are the principal point's xy-coordinates (roughly the middle of the image; again making sense) and (2,3) is the relative focal length (with respect to the image width).

    Don't scale the disparity. So comment this line:

    #disp = abs(disp-min_disp)/num_disp