【问题标题】:OpenCV Error: Unspecified error (could not find a writer for the specified extension) in imwrite_OpenCV 错误:imwrite_ 中的未指定错误(找不到指定扩展的写入器)
【发布时间】:2017-09-01 07:27:07
【问题描述】:

我已经安装了 opencv 1.0.1 版,当我使用 cv2.imwrite() 方法时,它会抛出以下错误

OpenCV Error: Unspecified error (could not find a writer for the
specified extension) in imwrite_, file
/io/opencv/modules/imgcodecs/src/loadsave.cpp, line 604 Traceback
(most recent call last):   File "scan.py", line 78, in <module>
findContours(image,screenCnt,orig,ratio,outputPath)   File /home/Verchaska/dev/aneesh/contours.py", line 26, in findContours
cv2.imwrite(filename,warped) cv2.error: /io/opencv/modules/imgcodecs/src/loadsave.cpp:604: error: (-2) could
not find a writer for the specified extension in function imwrite_

【问题讨论】:

  • cv2.imwrite()之前使用print filename,看看你是否传递了一个有效的extension
  • 是的,我检查过了,我正在传递“.jpg”扩展名
  • 使用.png 扩展名或其他可能的扩展名尝试一次。
  • 版本 1.0.1?真的吗?为什么要使用这个过时的版本?
  • 请分享您正在使用的示例代码

标签: python opencv


【解决方案1】:

您需要使用带有如下文件的扩展名:

filename = 'inference/output/images/imagename.jpg'
cv2.imwrite(filename, file) 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-09
    • 1970-01-01
    • 1970-01-01
    • 2017-05-06
    • 2015-12-22
    • 1970-01-01
    • 1970-01-01
    • 2020-02-19
    相关资源
    最近更新 更多