MM.
MM.

Reputation: 4274

How do I obtain the camera world position from calibrateCamera results?

I am performing camera calibration using calibrateCamera. Part of the output is a set of Rodrigues rotation vectors, and 3-D translation vectors.

I am interested in the world position of the cameras. If I plot the translation points directly, the results look incorrect. I feel that I am getting my coordinate spaces confused, but I am having trouble parsing the opencv documentation:

rvecs – Output vector of rotation vectors (see Rodrigues() ) estimated for each pattern view. That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the calibration pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. M -1).

My question is, how do I derive the camera world position from a Rodrigues rotation vector and corresponding translation vector obtained using opencv's calibratecamera?

Upvotes: 3

Views: 5155

Answers (1)

Ander Biguri
Ander Biguri

Reputation: 35525

From the opencv docs: world to camera coordinates

enter image description here

There are 2 matrices there, the intrinsic matrix and the extrinsic matrix.

The intrinsic matrix gives you the U,V coordinates (pixel) coordinates of something in the image if you have the XYZ coordinates IN THE CAMERA (centre in the middle). The extrinsic matrix gives you the coordinates IN THE CAMERA in XYZ from coordinates in the world.

Thus, you only need the extrinsic matrix for your objective.

You know that you want from XYZ in the camera to the world. As the extrinsic matrix is from world to camera, you just need to invert it!

Cworld=E^(-1)*Ccamera

and the camera coordinates in camera coordinate system are Ccamera=[0,0,0]

The extrinsic matrix is composed by two of the outputs from calibrateCamera, rvects and tvects.

Upvotes: 2

Related Questions