It is a learning memo.
When I was just starting to use OpenCV
#File reading
img = cv2.imread('./img.jpg')
###processing###
#File output
cv2.imwrite('./output', img)
Then, the following error occurred when outputting the file.
cv2.error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\imgcodecs\src\
loadsave.cpp:662: error: (-2:Unspecified error) could not find a writer for the
specified extension in function 'cv::imwrite_'
It seems that the cause was that I forgot to add the extension when outputting.
#File output
cv2.imwrite('./output.jpg', img)
With the extension, I was able to output safely.
By the way, the output seems to support the following formats.
jpg, jpeg, jpe, jp2, png, webp, bmp, pbm, pgm, ppm,
pxm, pnm, sr, ras, tiff, tif, exr, hdr, pic, dib
It was a problem that made me laugh when I noticed it, but when it happened, I was quite worried. I would like to devote myself to eliminating particularly simple oversights.
Thank you for visiting.
http://blog.livedoor.jp/airyglyph0000/archives/3969423.html http://lang.sist.chukyo-u.ac.jp/classes/OpenCV/py_tutorials/py_gui/py_image_display/py_image_display.html
Recommended Posts