cvStereoRectify does not provide accurate result for 3D triangulation (Bug #383)


Added by Jordi Pages over 14 years ago. Updated over 12 years ago.


Status:Cancelled Start date:
Priority:Normal Due date:
Assignee:Ilya Lysenkov % Done:

0%

Category:calibration, 3d
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

I have been testing cvStereoRectify to obtain matrices R, P and Q and then compute 3D triangulation in the rectified cameras. Finally, using the transposed R matrices I get the 3D points in the original camera frames.

I have noticed that triangulation accuracy is not good enough even if simulated cameras and simulated 3D points are used. I think that the problem appears in the result given in the P matrix corresponding to the right camera. According to OpenCV's documentation, this matrix looks like:

P' = [ f 0 Cx' Tx*f ]
[ 0 f Cy 0 ]
[ 0 0 1 0 ]

being Cx' the principal point x coordinate in the right camera and Cy the y coordinate of the principal point in both the left and right cameras. Then, it is stated that Tx is "the horizontal shift" between both cameras. As far as I have understood, rectification implies rotating the cameras so that they get aligned and both images planes are the same and the focal lengths are also equal. Nevertheless, the cameras' focal points are not moved, so that the distance between the camera focal points is the same before and after rectification. Then, this distance is Tx.

I have checked the value of Tx in P' matrix and it is slightly different to the distance between the focal points of the cameras before rectification. Furthermore, by setting Tx to the exact value and then recomputing matrix Q by hand, the triangulation accuracy obtained is much better.

Could anybody check this point?

Thanks in advance


Associated revisions

Revision f3ae185f
Added by Marina Kolpakova about 12 years ago

Merge pull request #383 from cuda-geek:apply-opencv-macosx-patch

History

Updated by anonymous - over 14 years ago

Replying to jordi_pages78:

I have been testing cvStereoRectify to obtain matrices R, P and Q and then compute 3D triangulation in the rectified cameras. Finally, using the transposed R matrices I get the 3D points in the original camera frames.

I have noticed that triangulation accuracy is not good enough even if simulated cameras and simulated 3D points are used. I think that the problem appears in the result given in the P matrix corresponding to the right camera. According to OpenCV's documentation, this matrix looks like:

P' = [ f 0 Cx' Tx*f ]
[ 0 f Cy 0 ]
[ 0 0 1 0 ]

being Cx' the principal point x coordinate in the right camera and Cy the y coordinate of the principal point in both the left and right cameras. Then, it is stated that Tx is "the horizontal shift" between both cameras. As far as I have understood, rectification implies rotating the cameras so that they get aligned and both images planes are the same and the focal lengths are also equal. Nevertheless, the cameras' focal points are not moved, so that the distance between the camera focal points is the same before and after rectification. Then, this distance is Tx.

I have checked the value of Tx in P' matrix and it is slightly different to the distance between the focal points of the cameras before rectification. Furthermore, by setting Tx to the exact value and then recomputing matrix Q by hand, the triangulation accuracy obtained is much better.

Could anybody check this point?

Thanks in advance

Updated by Alexander Shishkov about 13 years ago

  • Description changed from I have been testing cvStereoRectify to obtain matrices R, P and Q and then co... to I have been testing cvStereoRectify to obtain matrices R, P and Q and then co... More

Updated by Alexander Shishkov almost 13 years ago

  • Priority changed from High to Normal
  • Target version deleted ()

Updated by Ilya Lysenkov almost 13 years ago

  • Assignee set to Ilya Lysenkov

Updated by Ilya Lysenkov almost 13 years ago

Thank you for the report and for your investigation. Indeed, Tx should be equal to distance between cameras after rectification. I've added such a check in r7668. It works correctly on the OpenCV test data so probably it is fixed already. If you still experience this problem then re-open the issue and, please, provide your data when Tx and the distance are different.

  • Status changed from Open to Cancelled

Updated by Alexander Shishkov almost 13 years ago

  • Target version set to 2.4.0

Updated by Martin Beckett over 12 years ago

We have a similar problem in 2.4.2

In the projection matrix a common 'f' is calculated for all cameras and all axis.
But the TxF corresponds to either Tx between cameras multiplied by the actual Fx of left camera - or the total distance (Tx,Ty,Tz) multiplied by the common focal length 'f'. The difference is about 5%

We get an accurate 3D reconstruction from Triangulate points except for a 10% scale error.

Also available in: Atom PDF