In a nutshell...the translation matrix returned from decomposing a homography matrix is actually a 3X1 matrix (a vector really). Yet, every description of a translation matrix is a 3X2 matrix.
Here are the two images (IR camera), the position 1 image (approx camera cartesian coords x = 0mm, y=300mm):
This is the position 2 image (approx camera cartesian coords x = 680mm, y=0mm):
I used the following with +90 points to determine the homography matrix (M):
M, mask = cv2.findHomography(source_pts, destination_pts, cv2.RANSAC,5.0)
This process picked out a good number of keypoints:
If you apply this homography matrix to the original image -- it works perfectly:
im_out = cv2.warpPerspective(img1,M, (640,480) )
and the output of the difference between the point set:
np.mean(dst_pts-src_pts , axis = 0)
array([[-305.16345, -129.94157]], dtype=float32)
is fairly close to the dot product of the homography matrix for a single point....
np.dot(M,[1,1,1])
array([-293.00352303, -132.93478376, 1.00009461])
I decomposed the homography matrix with the following command:
num, Rs, Ts,Ns = cv2.decomposeHomographyMat(M, camera_matrix)
This returns 4 solutions (num), a rotation matrix, a translation matrix, and Ns (cant remember what it is).
I'm interested in the translation matrix.
Firstly... The translation matrix, lists the 4 solutions (Is this correct?):
Ts =
[array([[-0.60978834],[-0.26268874],[ 0.01638967]]),
array([[ 0.60978834], [ 0.26268874],[-0.01638967]]),
array([[-0.19035409],[-0.06628793],[ 0.63284046]]),
array([[ 0.19035409], [ 0.06628793],[-0.63284046]])]
Secondly, and most puzzling is that each of the solutions has 3 values...
e.g., the first solution: [-0.6097, -0.2626, 0.01638967].
My understanding is that a translation matrix would have the form of :
How do I get from the values returned from the decomposition matrix to the translation matrix in the form above? **ie... how do I convert this: [-0.6097, -0.2626, 0.01638967]
Thanks for your help.