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

后端 未结 4 1527
情话喂你
情话喂你 2021-01-04 14:24

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 =          


        
相关标签:
4条回答
  • 2021-01-04 14:35

    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.
    
    0 讨论(0)
  • 2021-01-04 14:39

    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)
    
    0 讨论(0)
  • 2021-01-04 14:43

    Add an extension for the output file like .jpg, .png, etc based on the application.

    For example in this case you could use,

    import cv2
    image = cv2.imread('Lena.jpg')
    cv2.imwrite('Mypic.jpg',image)
    
    0 讨论(0)
  • 2021-01-04 14:51

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

    0 讨论(0)
提交回复
热议问题