How can I get the camera projection matrix from calibrateCamera () values

I am trying to get a 3x4 camera matrix for the triangulation process, but calibrateCamera() returns only 3x3 and 4x1 matrices.

How can I get 3x4 from these matrices?

Thanks in advance!

+7
source share
2 answers

calibrateCamera () returns you a 3x3 matrix as cameraMatrix,
4x1 matrix as distCoeffs, and rvecs and tvecs, which are the vectors of the 3x1 (R) and 3x1 (t) transformation matrices.

What you want is ProjectionMatrix, which is multiplied by [cameraMatrix] by [R | t]. 3D into 2D Projection

Therefore, it returns you a 3x4 ProjectionMatrix.
You can read the OpenCV documentation for more information.

+11
source

If you use cameraCalibrate (), you should get mtx, rvecs and tvecs. R is 3x1 to be converted to 3x3 using the Rodriguez opencv method. Thus, the final code will look something like this:

 rotation_mat = np.zeros(shape=(3, 3)) R = cv2.Rodrigues(rvecs[0], rotation_mat)[0] P = np.column_stack((np.matmul(mtx,R), tvecs[0])) 

Assuming you used multiple images to calibrate the camera, here I use only the first to get the P-matrix for the first image. For any other image, you can use rvecs [IMAGE_NUMBER], tvecs [IMAGE_NUMBER] for the corresponding matrix P

0
source

All Articles