本文介绍了得到错误-在给imshow,imwrite命令opencv时'找不到作者'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是opencv和python的初学者.我刚刚安装了opencv2.4.9,并想到了canopy-32bit.我收到以下错误:

I am a beginner at opencv and python.I have just installed opencv2.4.9 and enthought canopy-32bit. I am getting error for the following:

import cv2
image = cv2.imread('Lena.jpg')
cv2.imwrite('Mypic',image)

这就是我得到的:

c:\users\nam\appdata\local\temp\tmpokspbt.py in <module>()
      3
      4 image = cv2.imread('Lena.jpg')
----> 5 cv2.imwrite('Mypic',image)

error: ..\..\..\..\opencv\modules\highgui\src\loadsave.cpp:275: error: (-2) could not find a writer for the specified extension in function cv::imwrite_

推荐答案

您需要对imwrite()进行扩展,以便知道如何保存(压缩)它.

you need to give an extension to imwrite(), so it knows, how to save(compress) it.

cv2.imwrite('Mypic.png',image)
# jpg,bmp,png,ppm,pgm,tiff supported 'out-of-the-box,
# webp,jp2 depending on if you compiled in the resp. 3rd party support
# no gif or tga.

这篇关于得到错误-在给imshow,imwrite命令opencv时'找不到作者'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 20:11