def get_affine_matrix(v1, v2, v3, new_v1, new_v2, new_v3): """ 根据三个坐标点的坐标变换获取相对应仿射矩阵 """ pts = np.float32([[v1[0], v1[1]], [v2[0], v2[1]], [v3[0], v3[1]]]) pts1 = np.float32([[new_v1[0], new_v1[1]], [new_v2[0], new_v2[1]], [new_v3[0], new_v3[1]]]) affine_matrix = cv2.getAffineTransform(pts, pts1) return affine_matrix