himanshu walia
himanshu walia

Reputation: 1

Distance measurement using Stereo vision opencv python

i want to measure distance of a object using a stereo camera set, till now i have calibrated and rectified my camera , generated disparity map.Using opencv stereo_match. But i am stuck on how to move forward to find the distance of an object in the image using disparity matrix. Also i am in doubt about the disparity matrix, can someone please explain it.What is the content of it. Also how to improve the disparity map , i have tried to change the parameters but with little success. Any help would be appreciated, some sample codes or any link.

Thank you

Upvotes: 0

Views: 14794

Answers (2)

Cosha
Cosha

Reputation: 11

There is a code on stereo-vision, using OpenCV and Python available on GitHub: https://github.com/LearnTechWithUs/Stereo-Vision

The explanations are in German though...

There is also a Youtube video of the project: https://www.youtube.com/watch?v=xjx4mbZXaNc

The program is able to measure the distance of an object present in the image.

Upvotes: 1

jodis
jodis

Reputation: 168

See https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#reprojectimageto3d

"Q – 4 x 4 perspective transformation matrix that can be obtained with stereoRectify()."

If you follow https://github.com/opencv/opencv/blob/master/samples/python/stereo_match.py you note in line 57 that you need to divide disp by 16.0 to get real dimensions.

As for the parameters: keep trying, it really depends on your setup. For minDisparity and numDisparities you can manually inspect your images to find a suitable range.

Upvotes: 0

Related Questions