1 | initial version |
np.shape()
returns a 3d array, while cv2.getRotationMatrix2D()
expects a 2d tuple for the center point.
you have to shave off the 3rd dimension (depth), to make it work:
center = tuple(np.array(image.shape)[:2]/2) # 2d ! rot_mat = cv2.getRotationMatrix2D(center,angle,1.0) result = cv2.warpAffine(image, rot_mat, image.shape,flags=cv2.INTER_LINEAR)
2 | No.2 Revision |
np.shape()
returns a 3d array, while cv2.getRotationMatrix2D()
expects a 2d tuple for the center point.
you have to shave off the 3rd dimension (depth), to make it work:
center = tuple(np.array(image.shape)[:2]/2) # 2d !
rot_mat = cv2.getRotationMatrix2D(center,angle,1.0)
result = cv2.warpAffine(image, rot_mat,