1 | initial version |
Rotation_matrix_T = cv.Rodrigues(rvec)[0]
Rotation_matrix = Rotation_matrix_T.T
Translate_vector = - np.dot(Rotation_matrix , tvec)
Transformation_matrix = np.eye(4)
Transformation_matrix[:3, :3] = Rotation_matrix
Transformation_matrix[:3, 3] = Translate_vector
## method 1 ##
proj_matrix = np.hstack((Rotation_matrix_T, - np.dot(Rotation_matrix_T, Translate_vector)))
## method 2 ##
proj_matrix = np.zeros(3, 4)
Transformation_matrix_inv = np.linalg.inv(Transformation_matrix)
proj_matrix = Transformation_matrix_inv[:3, :4]
# # # # # # # # # # # # # # # # # #
# # R | s*t # #
# # T = ------- # #
# # 0 0 0 1 # #
# # # #
# # R.T | -R.T*s*t # #
# # inv(T) = -------------- # #
# # 0 0 0 1 # #
# # # #
# # P = R.T| -R.T*s*t # #
# # P = inv(T)[:3, :4] # #
# # # # # # # # # # # # # # # # # #
This projection Matrix don't contain Camera Matrix
proj_matrix_Final_Camera1 = np.dot(cameraMatrix, np.eye(4)[:3, :4])
proj_matrix_Final_Camera2 = np.dot(cameraMatrix, proj_matrix)
2 | No.2 Revision |
Transformation_matrix = np.eye(4)
Transformation_matrix[:3, :3] = Rotation_matrix
Transformation_matrix[:3, 3] = Translate_vector
## method 1 ##
proj_matrix = np.hstack((Rotation_matrix_T, - np.dot(Rotation_matrix_T, Translate_vector)))
## method 2 ##
proj_matrix = np.zeros(3, 4)
Transformation_matrix_inv = np.linalg.inv(Transformation_matrix)
proj_matrix = Transformation_matrix_inv[:3, :4]
# # # # # # # # # # # # # # # # # #
# # R | s*t # #
# # T = ------- # #
# # 0 0 0 1 # #
# # # #
# # R.T | -R.T*s*t # #
# # inv(T) = -------------- # #
# # 0 0 0 1 # #
# # # #
# # P = R.T| -R.T*s*t # #
# # P = inv(T)[:3, :4] # #
# # # # # # # # # # # # # # # # # #
# s = Scale You don't need it now #
# # # # # # # # # # # # # # # # # #
This projection Matrix don't contain Camera Matrix
proj_matrix_Final_Camera1 = np.dot(cameraMatrix, np.eye(4)[:3, :4])
proj_matrix_Final_Camera2 = np.dot(cameraMatrix, proj_matrix)
3 | No.3 Revision |
Code:
Rotation_matrix_T = cv.Rodrigues(rvec)[0]
Rotation_matrix = Rotation_matrix_T.T
Translate_vector = - np.dot(Rotation_matrix , tvec)
tvec)
Transformation_matrix = np.eye(4)
Transformation_matrix[:3, :3] = Rotation_matrix
Transformation_matrix[:3, 3] = Translate_vector
## method 1 ##
proj_matrix = np.hstack((Rotation_matrix_T, - np.dot(Rotation_matrix_T, Translate_vector)))
## method 2 ##
proj_matrix = np.zeros(3, 4)
Transformation_matrix_inv = np.linalg.inv(Transformation_matrix)
proj_matrix = Transformation_matrix_inv[:3, :4]
# # # # # # # # # # # # # # # # # #
# # R | s*t # #
# # T = ------- # #
# # 0 0 0 1 # #
# # # #
# # R.T | -R.T*s*t # #
# # inv(T) = -------------- # #
# # 0 0 0 1 # #
# # # #
# # P = R.T| -R.T*s*t # #
# # P = inv(T)[:3, :4] # #
# # # # # # # # # # # # # # # # # #
# s = Scale You don't need it now #
# # # # # # # # # # # # # # # # # #
This projection Matrix don't contain Camera Matrix
proj_matrix_Final_Camera1 = np.dot(cameraMatrix, np.eye(4)[:3, :4])
proj_matrix_Final_Camera2 = np.dot(cameraMatrix, proj_matrix)
4 | No.4 Revision |
Code:
Rotation_matrix_T = cv.Rodrigues(rvec)[0]
Rotation_matrix = Rotation_matrix_T.T
Translate_vector = - np.dot(Rotation_matrix , tvec)
Transformation_matrix = np.eye(4)
Transformation_matrix[:3, :3] = Rotation_matrix
Transformation_matrix[:3, 3] = Translate_vector
## method 1 ##
proj_matrix = np.hstack((Rotation_matrix_T, - np.dot(Rotation_matrix_T, Translate_vector)))
## method 2 ##
proj_matrix = np.zeros(3, 4)
Transformation_matrix_inv = np.linalg.inv(Transformation_matrix)
proj_matrix = Transformation_matrix_inv[:3, :4]
# # # # # # # # # # # # # # # # # #
# # R | s*t # #
# # T = ------- # #
# # 0 0 0 1 # #
# # # #
# # R.T | -R.T*s*t # #
# # inv(T) = -------------- # #
# # 0 0 0 1 # #
# # # #
# # P = R.T| -R.T*s*t # #
# # P = inv(T)[:3, :4] # #
# # # # # # # # # # # # # # # # # #
# s = Scale You don't need it now #
# # # # # # # # # # # # # # # # # #
This projection Matrix don't contain Camera Matrix
proj_matrix_Final_Camera1 = np.dot(cameraMatrix, np.eye(4)[:3, :4])
proj_matrix_Final_Camera2 = np.dot(cameraMatrix, proj_matrix)
To answer your question: The rvec and tvec returned by solvepnp don't include the values of the camera matrix. The rotation and translation are recovered in this way
Rotation = cv.rodriges (rvec) [0] .T
Traslation = - np.dot (Rotation.T, tvec)