Search code examples
opencvgeometrypose-estimationmultiviewopencv-solvepnp

Absolute Pose of Cameras for two opposite views


I am following this Opencv Pose Estimation official tutorial to get absolute poses for two views, which are attached following.

As you can see, in this case, they are totally opposite to each other, therefore I am having a hard time getting the absolute rotation matrix and translation vector because it detects the top left corner in each view, which is wrong. I want this script to focus on the same box for both of the views. The top left box in Camera1.jpg will be the bottom right box in Camera2.jpg. How do I do that?

Earlier I have been using this tutorial to get R, t for two cameras views looking at the checkerboard from the same side, therefore it would work fine.

Camera1.jpg Camera1

Camera2.jpg Camera2


Solution

  • Note: your axes are colored unusually. Conventionally, X is red, Y is green, Z is blue.

    I see two options.

    1. You'll want a chessboard that has no rotational symmetry. Make sure the number of corners/steps/squares in one dimension is odd and even in the other. That'll imply a suitable board, and this ambiguity won't occur.

    2. You know the transformation between both "views" of the board. It's a 180 degree rotation around Z and a translation by the given number of squares. You can work that into your camera poses. I find it easiest to work with 4x4 pose matrices, not with rvec and tvec individually, because pose matrices compose easily (matrix multiplication, @ infix operator) and invert easily.