我试图估计一些图像的转换,并使用python中的stitcher.estimateTransform()
和{
pano is not a numpy array, neither a scalar
我试图使用cv2.fromarray(left)
将NumPy数组转换为Mat对象,但它只适用于cv,而不是cv2。所以我如何将这个numpy转换成cv2中的MAT数组呢。{t{t>使用python绑定的示例。对于这个错误的任何解决方案,或者将stitcher.estimateTransform()
与OpenCV Python绑定一起使用的例子,我们将不胜感激。在
注意:尽管OpenCV Python绑定中的缝合类并不完整(因为是自动生成的绑定),help(cv2.createStitcher())
表明它包含composePanorama()
和{
注意:我可以毫无问题地使用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])
要使用
stitcher.estimateTransform()
和stitcher.composePanorama()
,您需要然后构建python模块:
然后将模块从安装位置移到虚拟环境中。在我的例子中是/usr/local/lib/python3.7/site-packages/cv2。在
有关详细信息,请参见https://www.pyimagesearch.com/2018/08/17/install-opencv-4-on-macos/和https://docs.opencv.org/4.1.0/da/d49/tutorial_py_bindings_basics.html和https://docs.opencv.org/4.1.1/da/df6/tutorial_py_table_of_contents_setup.html。在
我也有同样的问题。据我所见,
composePanorama
有两个重载。在这是我们需要的第二个重载,因为
pano
是一个输出参数,在Python中它是作为返回值给出的。不幸的是,第二个重载没有用CV_WRAP
标记,这将使Python绑定可用。所以我能看到的唯一解决办法是:CV_WRAP
(我不确定它是否真的这么简单)不过,如果有人能在不经历上述复杂任务的情况下用Python发布一个答案,我将非常高兴。在
相关问题 更多 >
编程相关推荐