OpenCV stereo camera, determining the distance to the object

I'm new to OpenCV, Ive built openCV and installed Qt to successfully run the http://code.google.com/p/opencvstereovision/source/checkout example. As a result, the left and right webcam captures and after calibration, the rectified image for both maps and depth maps. I want to do the following. I click on an object to focus on any of these left or right images. Then I want to determine the corresponding pixel in another image and calculate the distance to this object. I do not know what to do now, and I need to be guided. Maybe if I calculate the corresponding point first, I can solve the problem. How can i do this?

+4
source share
2 answers

It would seem that you have a good idea of ​​what is required. It might be a little worm - so I would recommend getting the famous Hartley and Sisserman book for a canonical explanation. Here is a link to the corresponding chapter.

But in a nutshell ...

I did not use the opencvstereovision shell class directly, but it looks like it took the headache out of calibration (internal and external cameras) and calculated straightening through the homography matrix (H) for planar geometry or the fundamental matrix (F) for more complex epipolar geometry.

Probably similar to this original post .

This means that this correction means that it has established a mathematical comparison between the same point in each image.

In the previous answer (from me) you can do the math using the Fundamental matrix to perform triangulation - i.e. distance calculations.

However, note that this distance is only in the frame of the image coordinates (i.e. in pixels).

What is really needed to take measurements of the β€œreal world” (ie, the actual physical distance) is the calculation of the main matrix (E), which combines the main matrix and the internal properties of the cameras (K) with, if you want, project the distances into the real world.

+4
source
class StereoVar { StereoVar(); StereoVar( int levels, double pyrScale, int nIt, int minDisp, int maxDisp, int poly_n, double poly_sigma, float fi, float lambda, int penalization, int cycle, int flags); virtual ~StereoVar(); virtual void operator()(InputArray left, InputArray right, OutputArray disp); int levels; double pyrScale; int nIt; int minDisp; int maxDisp; int poly_n; double poly_sigma; float fi; float lambda; int penalization; int cycle; int flags; ... }; 

Refer to: http://docs.opencv.org/modules/contrib/doc/stereo.html

+1
source

All Articles