how can i get the camera projection matrix out of calibrateCamera() return values

前端 未结 2 559
执念已碎
执念已碎 2021-02-15 11:11

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

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-15 11:38

    If you are using cameraCalibrate(), you must be getting mtx, rvecs and tvecs. R is 3x1 which you need to convert to 3x3 using Rodrigues method of opencv. So the final code will look something like:

    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 have used multiple images for calibrating camera, here I am using only the first one to get P matrix for first image. For any other image you can use rvecs[IMAGE_NUMBER], tvecs[IMAGE_NUMBER] for the corresponding P matrix

提交回复
热议问题