def rotateImage(image, phi, theta, psi):
"""
Rotate an image
:param image: (cv2 image object)
:param phi: (float)
:param theta: (float)
:param psi: (float)
:return: (cv2 image object)
"""
# Height, Width, Channels
h, w, c = image.shape
F = np.float32([[300, 0, w / 2.], [0, 300, h / 2.], [0, 0, 1]])
R = rotMatrix([phi, theta, psi])
T = [[0], [0], [1]]
T = np.dot(R, T)
R[0][2] = T[0][0]
R[1][2] = T[1][0]
R[2][2] = T[2][0]
M = np.dot(F, np.linalg.inv(np.dot(F, R)))
out = cv2.warpPerspective(image, M, (w, h))
return out
评论列表
文章目录