Question

I'm working on a problem where I have a calibrated stereo pair and am identifying stereo matches. I then project those matches using perspectiveTransform to give me (x, y, z) coordinates.

Later, I'm taking those coordinates and reprojecting them into my original, unrectified image using projectPoints with takes my left camera's M and D parameters. I was surprised to find that, despite all of this happening within the same calibration, the points do not project on the correct part of the image (they have about a 5 pixel offset, depending where they are in the image). This offset seems to change with different calibrations.

My question is: should I expect this, or am I likely doing something wrong? It seems like the calibration ought to be internally consistent.

Here's a screenshot of just a single point being remapped (drawn with the two lines):

stereo

(ignore the little boxes, those are something else)

Was it helpful?

Solution

I was doing something slightly wrong. When reprojecting from 3D to 2D, I missed that stereoRectify returns R1, the output rectification rotation matrix. When calling projectPoints, I needed to pass the inverse of that matrix as the second parameter (rvec).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top