You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何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输出结果:
    OpenCV输出结果

  • TensorFlow输出结果:
    TensorFlow输出结果

内容的提问来源于stack exchange,提问作者Panda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 16:33:32