3

i have a stereopair, photo 1: http://savepic.org/1671682.jpg photo 2: http://savepic.org/1667586.jpg

there is coordinate system in each image. How can I find coordinates of point A in this system using OpenCV library. It would be nice to see sample code. I've looked for it at opencv.willowgarage.com/documentation/cpp/camera_calibration_and_3d_reconstruction.html but haven't found (or haven't understood :) )

1
  • 1
    linkrot, your images are no longer accessible
    – nmz787
    Jan 25, 2021 at 17:36

3 Answers 3

4

Your 'stereo' images are fine. What you have already done is solve the correspondence problem: in both images you have indicated points 'A'. This means that you know which pixel corresponds to eachother labeling point 'A'.

What you want to do, is triangulate where your camera is. You can only do this by first calibrating your camera. This is inside of OpenCV already. http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html

This gives you the exact vector/ray of light for each vector, and the optical center of your cameras through which the ray passes. Moreover, you need stereo calibration. This establishes the orientation and position of each camera with respect through each other.

From that point on, your triangulation is simple, knowing the pixel location in both images of point 'A'. You have

  • Location and orientation of camera 1 and camera 2
  • Otical Ray Vector (pixel location) from the cameras to label 'A'.

So you have 2 locations in space, and 2 rays from these location. The intersection of these rays is your 3D answer.

Note that in practice there rays will never exactly intersect (2 lines in 3D rarely do), so you need to approximate. Use opencv function triangulatePoints(), using the input of the stereo calibration and the pixel index relating to label A.

1
-1

Firstly of all this is not truly a stereo pair. A nice stereo pair needs to have 60%-80% overlap usually small rotation differences between images. Even if this pair had the necessary BASE to be a good stereo pair due to the extremely kappa rotation the resulting epipolar image would be useless.

Secondly among others you should take a look at the camera calibration and collinearity equations both supported by OpenCV

http://en.wikipedia.org/wiki/Camera_resectioning

http://en.wikipedia.org/wiki/Collinearity_equation

3
  • You seem to be limited by your own experience. This is a fine stereo pair, has decent overlap and decent rotation. I have had excellent results with a 70 degree rotation and a 70cm distance between cameras. The fact that the result is awesome means that all you just said is nonsense. See our setup and resulting 3D maps here: youtube.com/watch?v=er5N1Zv3oac
    – TimZaman
    Mar 4, 2015 at 14:29
  • depending on what exactly is your final goal, with such stereopair you can only get relative depth scales and almost no usefull measuring data. I admit my experience is limited only to huge photogrammetry projects like this one acropolis-gis.ysma.gr/el/… Mar 5, 2015 at 16:45
  • 1
    Utterly untrue. It's just a simple matter of having 2 points (2 optical centers) and 2 vectors and just triangulate. You should know that 'small rotations' and the amount of overlap really have no meaning at all. If i take 9 images with a 40 degree angle i can still make a 3D model through photogrammetry. From this you would learn that the amount of degrees is fine. An absolute scale is easily obtained since the absolute positions of the reference points are given. Your epipolar images would NOT be useless, they would just not be square. Trust me, been there, done that, works. See link.
    – TimZaman
    Mar 5, 2015 at 21:16
-4

You need to understand the maths.

If the page isn't enough then you should look at the opencv book - it devotes a couple of chapters to this. Then there are a lot of textbooks that cover it in more detail

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.