Getting error - 'could not find a writer'while giving imshow, imwrite command opencv

本秂侑毒 提交于 2019-11-30 19:11:31

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.

You need to make sure you have the image type within the string you give to the imwrite(). imwrite() dose not have a default method to save, thus it is required within the name you give to it. instead of : cv2.imwrite('Mypic',image) you need to write :

cv2.imwrite('Mypic.The_format_you_want_to_save',image)

As an example:

cv2.imwrite('Mypic.jpg',image)

I could solve this problem by simply adding the extension '.jpg' etc at the end of the image and it worked for me!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!