我的问题与我问的另一个问题有关。但在这里我试图更准确地理解使用 cv2.getAffineTransform 获得的 warp_matrix 的组成。我在这找到了如何分解仿射变换矩阵,尤其是如何获得旋转角度
但是当使用OpenCV Doc 中的示例时,我获得了两个不同的旋转角度。
编码 :
import cv2
import numpy as np
pts1 = np.float32([[50,50],[200,50],[50,200]])
pts2 = np.float32([[10,100],[200,50],[100,250]])
M = cv2.getAffineTransform(pts1,pts2)
theta0=np.degrees(np.arctan(-M[0,1]/M[0,0]))
theta1=np.degrees(np.arctan(M[1,0]/M[1,1]))
print(theta0)
print(theta1)
Run Code Online (Sandbox Code Playgroud)
生产 :
-25.3461759419
-18.4349488229
Run Code Online (Sandbox Code Playgroud)