# Estimate Camera transform from chessboard transform

**URL:** <https://forum.opencv.org/t/estimate-camera-transform-from-chessboard-transform/18251>\
**Category:** Python\
**Tags:** calib3d\
**Created:** [July 12, 2024, 4:42pm UTC](https://forum.opencv.org/t/estimate-camera-transform-from-chessboard-transform/18251 "2024-07-12T16:42:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![helmetlabatVT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/helmetlabatvt/32/8062_2.png) [@helmetlabatVT](https://forum.opencv.org/u/helmetlabatVT)\
**Post date:** [July 12, 2024, 4:42pm UTC](https://forum.opencv.org/t/estimate-camera-transform-from-chessboard-transform/18251/1 "2024-07-12T16:42:27Z")

</div>

I am trying to estimate the translation and rotation of my camera relative to the chessboard calibration pattern. I have calibrated my camera, and I am able to get the tvec and rvec of the chessboard in the camera coordinate system using solvePNP, as well as verify the validity of these axes using drawFrameAxis.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/0/079e154dd43fb13006b86ae841a3c355f3a77861.jpeg)

I then try to get the camera transform with the following code:

```auto
def get_camera_transform(rvec: np.ndarray, tvec: np.ndarray):
    #Convert rotation vector to matrix
    r_board_to_cam, _ = cv2.Rodrigues(rvec)
    #Rotation matrix should be orthogonal so taking transpose gives inverse
    r_cam_to_board = r_board_to_cam.T
    t_cam_to_board = np.dot(-r_cam_to_board, tvec)
    #Convert matrix back to vector
    r_cam_to_board_v, _ = cv2.Rodrigues(r_cam_to_board)
    return np.degrees(r_cam_to_board_v), t_cam_to_board

```

My translation vector seems fine, but the rotation doesn’t seem to be accurate or offset by any constant factor that I can determine. I thought that taking the inverse of the initial rotation matrix would work, but it doesn’t produce the result I expected. Perhaps it has something to do with the rodrigues algorithm?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 13, 2024, 1:08am UTC](https://forum.opencv.org/t/estimate-camera-transform-from-chessboard-transform/18251/2 "2024-07-13T01:08:03Z")

</div>

the inverse is the correct path.

you might want to work with 4x4 matrices instead of carrying R and t individually.

to simplify the rotation between camera and board, you might wanna define the coordinate axes on the board to be somewhat like the camera’s. if your red is X and green is Y… then maybe define X to point right on the board, and Y down instead.
