我正在尝试使用OpenCV对整个图像应用透视变换。为此,我首先根据选定的点计算一个初始变换,然后尝试变换图像的角点并将它们转换为最终的最佳变换。我成功地获得了转换,但是应用cv2.perspectiveTransform()函数总是会引发以下错误:
OpenCV Error: Assertion failed (scn + 1 == m.cols && (depth == CV_32F || depth == CV_64F)) in perspectiveTransform, file /tmp/opencv-PEaA0A/opencv-2.4.9/modules/core/src/matmul.cpp, line 1936
我提供给函数的两个numpy数组都是float64数据类型,因此我假定错误来自scn+1==m.cols。以下是我的代码快照:
initTransform = cv2.getPerspectiveTransform(pointsIn,pointsOut)
imgCorners = np.array([[0,0],[self.image.size/float(self.image.shape[0]),0]],dtype=np.float64)
outputCorners = cv2.perspectiveTransform(corners,initTransform)
谢谢你的帮助!
目前没有回答
相关问题 更多 >
编程相关推荐