-1

I'm able to calculate the camera calibration using OpenCV in Python. However, what I really need is the projection matrix. Looking at the equations from the docs, it looks like this is P = K[R|T] where K is the intrinsic matrix, R is the rotation matrix, and T is the translation vector. This is the code that I made to compute the projection matrix:

ret, matrix, distCoef, rvecs, tvecs = cv2.calibrateCamera([world_points], [corners], gray.shape[::-1], flags=cv2.CALIB_USE_INTRINSIC_GUESS)

K = matrix
R = cv2.Rodrigues(rvecs[0])[0]
T = tvecs[0]
RT = np.concatenate((R,T),axis=1)
P = np.dot(K, RT)

Is this correct? To my understanding, I should be able to check it by doing P * [x; y; z; 1] where (x,y,z) is a world point, and the output ought to be the corresponding pixel coordinate. I tried this, but the outputs look very wrong. Does this mean it was a bad calibration, or did I construct P incorrectly?

Booley
  • 819
  • 1
  • 9
  • 25

1 Answers1

-1

I think I fixed it--as it turns out, I gave in some bad parameters to calibrateCamera(). I rewrote the code largely based off of calibrate.py that came with the OpenCV samples folder. I followed the rest of the concepts I mentioned in my original post (constructing P, checking reprojection error, etc.) and it gives me much more reasonable results now.

Booley
  • 819
  • 1
  • 9
  • 25