简体   繁体   English

Python Opencv图像拼接创建空文件

[英]Python Opencv Image Stitching Creates Empty file

I am using Python 3 and when running this code i end up with an empty file named "result.jpg". 我使用的是Python 3,运行此代码时,我得到一个名为“ result.jpg”的空文件。 Would appreciate any help, thanks; 感谢您的帮助,谢谢;

import cv2
stitcher = cv2.createStitcher(True)
foo = cv2.imread("one.jpg")
bar = cv2.imread("two.jpg")
result = stitcher.stitch((foo,bar))
cv2.imwrite("result.jpg", result[1])

I have no errors showing, just the empty file output. 我没有显示任何错误,只是空文件输出。 Is there an error if the function fails to stitch the images together? 如果该功能无法将图像拼接在一起,是否会出现错误?

If the stitched image is empty it probably means there was an error. 如果缝合的图像为空,则可能表示存在错误。

Notice that result[0] returns the status of the panorama stitching. 请注意,结果[0]返回全景针迹的状态。 According to the status you can understand what error was encountered. 根据状态,您可以了解遇到了什么错误。

From the documentation: 从文档中:

Status { 
  OK = 0, 
  ERR_NEED_MORE_IMGS = 1, 
  ERR_HOMOGRAPHY_EST_FAIL = 2, 
  ERR_CAMERA_PARAMS_ADJUST_FAIL = 3 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM