为何tfg.perspective_transform与cv2.warpPerspective透视变换结果不一致?
图像透视变换:OpenCV与TensorFlow Graphics输出不一致问题
我在使用cv2.warpPerspective和tfg.image.transformer.perspective_transform进行图像透视变换时,发现尽管用了相同的变换矩阵计算公式,二者输出结果却不匹配。但有意思的是,只要反转其中一个函数里的3D旋转矩阵,输出就能完全对齐。
测试代码
image = cv2.imread('test.png') image_height, image_width, _ = image.shape camera1_to_camera2_matrix = np.dot(np.dot(camera2_matrix, scale_matrix), np.dot(Rotation_matrix, np.linalg.inv(camera1_matrix))) # transformation matrix opencv_output = cv2.warpPerspective(image, camera1_to_camera2_matrix,(Height, Width)) tensorflow_result = tfg.image.transformer.perspective_transform(np.expand_dims(image.astype('float64'), axis=0), np.expand_dims(camera1_to_camera2_matrix, axis=0)).numpy()[0]
测试素材与结果
输入测试图像:

OpenCV输出结果:

TensorFlow输出结果:

内容的提问来源于stack exchange,提问作者Panda
相关产品推荐
相关产品推荐

