OpenCV imwrite 2.2 causes exception with message “OpenCV Error: Unspecified error (could not find a writer for the specified extension)” on Windows 7

前端 未结 3 2049
灰色年华
灰色年华 2021-01-02 06:25

I\'m porting an OpenCV 2.2 app from Unix (that works) onto Windows 7 64-bit and I receive the following exception when cv::imwrite is called

\"OpenCV Error: Unspecif

3条回答
  •  误落风尘
    2021-01-02 06:43

    From the OpenCV 2.2 API:

    The function imwrite saves the image to the specified file. The image format is chosen based on the filename extension, see imread for the list of extensions. Only 8-bit (or 16-bit in the case of PNG, JPEG 2000 and TIFF) single-channel or 3-channel (with ‘BGR’ channel order) images can be saved using this function. If the format, depth or channel order is different, use Mat::convertTo , and cvtColor to convert it before saving, or use the universal XML I/O functions to save the image to XML or YAML format.

    You might have more luck converting your file to 8 or 16 bits before saving.

    However, even with single channel 8 bit files I have had unknown extension errors trying to save jpg or png files but found that bmp works.

提交回复
热议问题