cv::imwrite could not find a writer for the specified extension

后端 未结 7 916
慢半拍i
慢半拍i 2020-12-25 12:24

The following command causes an exception.

cv::imwrite(\"test.jpg\", diffImg);

I also tried numerous variations on this, including absolute

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-25 12:59

    You need to recompile OpenCV and add support to "jpeg" format. Get the lastest opencv code and run cmake:

    svn co http://code.opencv.org/svn/opencv/trunk/opencv myopencvdir.svn/
    cd myopencvdir.svn/
    mkdir release
    cd release/
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
    

    And check if libjpeg, libpng, libtiff are supported. If not you need to install them and re-run cmake.

    Example of cmake output that shows Media I/O support:

    --   Media I/O: 
    --     ZLib:                       TRUE
    --     JPEG:                       TRUE
    --     PNG:                        TRUE
    --     TIFF:                       TRUE
    --     JPEG 2000:                  TRUE
    --     OpenEXR:                    YES
    

提交回复
热议问题