Confusion about homography matrix

Viewed 453

I'm trying to get a homography matrix that describes the transformation from one image to another. I tried doing this by using an eigendecomposition and taking the smallest eigenvector. Apparently, I have to reshape it into a 3x3 matrix, but the numpy linalg function returns an eigenvalue of shape (9,9). (trying to compute it from 4 points)

A is a 8x9 matrix. pts1 and pts2 are arrays of 4 points in the source image and the target image respectively.

Code starts from symmetry matrix for homography calculation (size 8x9)

A_t = A.transpose()
sym_mat = np.dot(A_t,A)

eig_val,eig_vec = np.linalg.eig(sym_mat)

#sort according to value
idx = np.argsort(eig_val)
eig_val = eig_val[idx]
eig_vec = eig_vec[:,idx]
# Return the eigenvector corresponding to the smallest eigenvalue, reshaped
# as a 3x3 matrix.
H = np.reshape(smallest,(3,3))

`

0 Answers
Related