1 | initial version |
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