Calculate relative 3D position from points in stereo images?

Hi everybody,

I have a (DIY) stereo camera readily calibrated so that it can be used with stereo_image_proc which successfully and beautifully creates a point cloud. That's nice so far... but it's not the question.

In addition to the image data (RGB) I also have several key points in image coordinates (x, y) that are generated from the pictures of both, the left and the right eye of the stereo camera. I would like to match these points so that I can calculate the Z-component for each point. That is, I have x1, y1, x2, y2 for each corresponding point and I'd like to have a full blown relative (and later on through tf absolute) x, y, z position for each point.

Thanks a lot!

//edit: oh, just to add to it: It is known which key point in the left corresponds to which one in the right image. That is, there is no feature matching necessary.

edit retag close merge delete

I'm slightly confused: you mention you already have pointclouds, so that implies that dense-stereo matching / processing is already working and disparity can be (successfully?) calculated. Are you now asking to do the same thing again, but for some specific features in both images?

( 2017-09-28 10:46:51 -0600 )edit

Sort by » oldest newest most voted

You've got all the information from the stereo calibration to construct an image_geometry::StereoCameraModel. You could use the projectDisparityTo3d function from the StereoCameraModel to get the 3D coordinates. Your input is a pixel location in rectified image (u, v) and the corresponding disparity (x2 - x1).

more

Works like a charm. Thanks a lot!

( 2017-10-05 10:04:04 -0600 )edit

You`ll want to use OpenCV's triangulatepoints function, which is doing exactly what you're asking for (unless I misinterpreted your question :) ).

more