OpenCV imwrite params读取访问冲突

OpenCV imwrite params读取访问冲突

问题描述:

一个非常简单的问题...为什么我收到此代码的读取访问冲突错误?

A very simple question...why am I getting a read access violation error with this code?

cv::Mat laserSpeckle = Mat::zeros(100,100,CV_8UC1);
imwrite( "C://testimage.jpg", laserSpeckle );

当我附加调试器并进一步查看它时,它会在 grfmt.cpp 中的此代码段中引发异常.

When i attach a debugger and look into it further, it throws the exception at this snippet in grfmt.cpp.

if( params[i] == CV_IMWRITE_JPEG_QUALITY )
        {
            quality = params[i+1];
            quality = MIN(MAX(quality, 0), 100);
        }

它也会出现在 .png 和 .tiff 中.我是 OpenCV 新手,如果这真的很简单,我很抱歉.我使用 Qt 是为了它的价值.

It occurs with .png and .tiff too. Im an OpenCV newbie, my apologies if this is something really simple. I am using Qt for what its worth.

您自己构建 OpenCV 吗?如果是,请确保在配置构建文件时启用选项 WITH_JPEG:

Do you build OpenCV yourself? If yes, make sure that the option WITH_JPEG is enabled when you configure your build files:

cmake ... -DWITH_JPEG=ON ...