2

I have read lots of questions both here on stackoverflow and on OpenCV Q/A, but still I can't solve my problem.

I need to estimate the world coordinate of my camera. This is my workflow:

  • First of all, I need to calibrate my camera. To speed up things, I'm using a virtual camera. Therefore I have rendered some images. This is an example:

    enter image description here

    I've rendered 10 of them. Since it a CG camera, I already know all its parameters, but the project will eventually use real camera, so I need to calibration process. To calibrate my camera, I'm using cv2.calibrateCamera(). This function gives me:

    • camera matrix

    • distortions

    • rvecs

    • tvecs

    Matrix camera is OK since its values match those of my virtual camera.

  • Now I'd like to see if I can estimate the position of the camera in the image D using tvec and rvec related to image D. To do so, I'm doing:

    • Get rotation matrix R with:cv2.Rodrigues(rvec, R)

    • Get the position of the camera with: C = - np.matmul(R.T, tvec)

Unfortunatly, the position C completely differs from the position of the camera in the 3D software.

Finally, I have no idea on how to use rvec to estimate the rotation of the camera so that it sees the chessboard pattern in the same way the virtual camera does in the 3D software.

Neb
  • 2,270
  • 1
  • 12
  • 22
  • Interesting problem to solve, nicely posed question ... but unfortunately on the edge of "[on-topic](https://stackoverflow.com/help/on-topic)" for SO - we cater to programming related problems. If you implement the math (using np or whatever) and got problems, please come back with it :) together with the code you have problems with. +1 still. – Patrick Artner Mar 17 '18 at 11:55
  • If you have R (from the rodrigues) and tvec, you can construct your transformation matrix (4x4 matrix) with [R|T] This means, the upper left side is the R matrix you put then as is the T vector as the 4th column, and the last row is just [0, 0, 0,1]. This will give the transformation from the **model** to the camera!!. This means that whatever coordinate origin you pass as imagePoints the transformation will go from there to the camera to get that image. – api55 Mar 17 '18 at 12:17
  • @PatrickArtner Unfortunatly, I haven't enough knowledge in computer vision so I was find a workflow that involved a library/framework..I opted for openCV. – Neb Mar 17 '18 at 12:20
  • @api55 that doesn't solve my problem. I need camera position in world coordinates – Neb Mar 17 '18 at 12:20
  • You should print expected and actual `R`, `t`. The ouput `rvecs` and `tvecs` are the rotation and translation vectors that transforms a 3D point expressed in the chessboard frame to the camera frame. For your rendering software, maybe you have a transformation between world frame and chessboard frame and another transformation between world frame and camera frame. If so, chessboard to camera transformation should be `chessboard_to_camera = world_to_chessboard^-1 x world_to_camera`. – Catree Mar 17 '18 at 13:16
  • @Neb world coordinates? what is the origin (point (0,0,0) ) of it? or better, in which coordinates is your phantom located? the rvec and tvec is relative to the coordinates where your phantom is located.... btw, world coordinates may change everytime depending on what you call origin in this world coordinates – api55 Mar 17 '18 at 13:28
  • @api55 the origin (0, 0, 0) is in the center of the chessboard in all images. I only changed the position (and orientation) of the camera in each image. – Neb Mar 17 '18 at 14:47
  • See [this answer](https://stackoverflow.com/a/49288096/3871028) – Ripi2 Mar 17 '18 at 17:06

0 Answers0