# How to find rotation angle from homography matrix?

I have 2 images and i am finding simliar key points by SURF. I want to find rotation angle between the two images from homograpohy matrix. Can someone please tell me how to find rotation angle between two images from homography matrix.

 if len(good)>MIN_MATCH_COUNT:
src_pts = np.float32([ kp1[m.queryIdx].pt for m in good ]).reshape(-1,1,2)
dst_pts = np.float32([ kp2[m.trainIdx].pt for m in good ]).reshape(-1,1,2)

M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)


Thank you.

edit retag close merge delete

Sort by » oldest newest most voted

findHomography might return an empty Mat, if it could not find a good transformation, so you need to check for that !

then it's just maths:

        if np.shape(M) == ():
print( "No transformation possible" )
return None, None

## derive rotation angle from homography
theta = - math.atan2(M[0,1], M[0,0]) * 180 / math.pi

more

Thankyou..works for me...sorry cant upvote since its showing points should be greater than 5

Official site

GitHub

Wiki

Documentation