我正在尝试估计一些图像的变换并在 python 中使用stitcher.estimateTransform()和stitcher.composePanorama()缝合它们。估计变换后,composePanorama 给出如下错误:
pano 不是 numpy 数组,也不是标量
我尝试使用 将 NumPy Array 转换为 Mat 对象cv2.fromarray(left),但它仅适用于 cv,不适用于 cv2。因此,如何在 cv2 中将此 numpy 转换为 MAT 数组。我没有找到任何使用composePanoramapython 绑定的例子。对此错误的任何解决方案或使用stitcher.estimateTransform()OpenCV-Python 绑定的示例将不胜感激。
注意:尽管 OpenCV-Python 绑定中的 Stitching 类不完整(由于自动生成的绑定),help(cv2.createStitcher())但表明它包含composePanorama()和estimateTransform().
注意:我可以stitcher.stitch()毫无问题地使用,但使用stitcher.stitch()对我没有帮助,因为我试图不计算主循环中每次迭代的变换。
我的简单代码:
leftStream = cv2.VideoCapture(0)
rightStream = cv2.VideoCapture(1)
left = leftStream.read()[1]
right = rightStream.read()[1]
st = cv2.createStitcher(False)
st.estimateTransform([left, right])
st.composePanorama([left, right])