【发布时间】:2015-01-03 18:48:44
【问题描述】:
我正在尝试实现以下paper,它将图像转换为鸟瞰图,但是当我使用以下代码执行此操作时,它并没有给我预期的结果。
import cv2
import numpy as np
tilt = np.pi * 35 / 180
src = cv2.imread("images/aaa.png")
width, height, depth = src.shape
# Intrinsic parameters of the Camera
calibrate = np.array([[1000, 0, 800],
[0, 1200, 100],
[0, 0, 1]], dtype=np.float32)
# The transformation matrix
b = np.array([[1, 0, 0],
[0, np.sin(tilt), -np.sin(tilt)],
[0, np.cos(tilt), np.cos(tilt)]], dtype=np.float32)
# Homography Matrix
result = np.mat(calibrate) * np.mat(b)
print result
output = cv2.warpPerspective(src, result, (height, width))
cv2.imwrite("theresult.png", output)
print output
源图片是:
应该计算的结果:
我得到的结果:
我不知道出了什么问题,因为我做的和纸上的一模一样。如果有替代方案,即使是 C++,请务必提供给我。
【问题讨论】:
-
我可以告诉你,源和假定结果之间的总 Homography(H 包括 C 已经在纸上 - 公式 6)应该接近:
[2.2, 6.7, -181; -0.4, 14.3, -637; 0, 0.03, 1]但我看不到相乘的方法C 的矩阵的顶部和左侧为零以获得该结果 -
太棒了!如果我可以问,你是怎么得到这个矩阵的?你能对矩阵进行逆向工程以获得方程吗?非常感谢您的帮助!
-
我通过手动选择两个图像中的点对应关系得到矩阵,并从中计算单应性。在本文中,我不理解将 M 的一列设置为零以及如何从 (5) 到 (6) 的假设,所以这些假设可能存在问题?
标签: python c++ opencv homography