Closed keqizero closed 4 months ago
Hi,
The overall process of computing the homography matrix is:
Some reference code if you have camera calibration files:
intr_mat, rvec, tvec = readFile(extr_file, intr_file)
r_mat = cv2.Rodrigues(rvec)[0]
tvec_T = np.transpose(tvec)
extr_mat = np.concatenate((r_mat, tvec_T), axis=1)
projection_matrix = intr_mat * extr_mat
# Homography Matrix
p11 = projection_matrix[0,0]
p12 = projection_matrix[0,1]
p14 = projection_matrix[0,3]
p21 = projection_matrix[1,0]
p22 = projection_matrix[1,1]
p24 = projection_matrix[1,3]
p31 = projection_matrix[2,0]
p32 = projection_matrix[2,1]
p34 = projection_matrix[2,3]
homography_matrix = np.array([[p11,p12,p14], [p21,p22,p24], [p31,p32,p34]], dtype=float)
For more details, there are lots of articles about computing homography matrix by calibration parameters.
@keqizero and @chengche6230 Hi, I have two cameras of GoPro10 but I can not figure out how to get extrinsic and intrinsic parameters.
Can you both help me with how I can get the extrinsic and intrinsic parameters of my cameras?
Thanks a lot.
Hi, @durbin-164
Just Google it. ^^ There are lots of resources about camera calibration.
Hi,
The overall process of computing the homography matrix is:
- Get intrinsic matrix, rvec (rotation vector), tvec (translation vector) by camera intrinsic and extrinsic parameters.
- Get extrinsic matrix by rvec and the transpose of tvec.
- Projection matrix can be calculated by multiplication of intr_mat and extr_mat.
- Homography matrix is composed of the nine elements of projection matrix.
Some reference code if you have camera calibration files:
intr_mat, rvec, tvec = readFile(extr_file, intr_file) r_mat = cv2.Rodrigues(rvec)[0] tvec_T = np.transpose(tvec) extr_mat = np.concatenate((r_mat, tvec_T), axis=1) projection_matrix = intr_mat * extr_mat # Homography Matrix p11 = projection_matrix[0,0] p12 = projection_matrix[0,1] p14 = projection_matrix[0,3] p21 = projection_matrix[1,0] p22 = projection_matrix[1,1] p24 = projection_matrix[1,3] p31 = projection_matrix[2,0] p32 = projection_matrix[2,1] p34 = projection_matrix[2,3] homography_matrix = np.array([[p11,p12,p14], [p21,p22,p24], [p31,p32,p34]], dtype=float)
For more details, there are lots of articles about computing homography matrix by calibration parameters.
Thank you!
Hi, thank you for the great work!
I have a question regarding the computation of homography matrix computation. As far as I'm concerned, homography matrix is the coordinate mapping between two pixel coordinate system, where there is pure rotation. But the translation vector exists, and I don't know which plane should the coordinates of all the cameras be mapped into. Therefore, I wanna ask how did you compute the matrix?
PS: for the custom dataset, I already have the extrinsic and intrinsic parameters of each camera.
Thank you!