OpenCV写入文件时出现未处理的异常 [英] OpenCV Unhandled exception when writing a file

查看:233
本文介绍了OpenCV写入文件时出现未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试不同的东西后,我的程序总是在保存图像时崩溃。它读得好的图像,我能够可视化,但我不能保存文件(它发生在所有程序,我使用OpenCV,而使用imwrite)。它在使用OpenCV 2.1在Visual Studio 10.0中调试时发生:

After trying different things, my program always crashes while saving an image. It reads well the image and I'm able to visualize it but I can't save files (it occurs in all programs that I make with OpenCV while using imwrite). It occurs while debugging in Visual Studio 10.0 with OpenCV 2.1:

Unhandled exception at 0x67570fcd in SR.exe: 0xC0000005: Access violation reading location 0x00000000.

这里的代码:

Mat imLow;

imLow=imread("Cameraman256.png",0);
if(!imLow.data)                             
{
    std::cout<<  "Could not open or find the image" << std::endl ;
    return -1;
}
imwrite( "image.png", imLow);

任何人都可以告诉我如何解决这个问题?谢谢

Can anyone tell me how can I fix this? Thank you

UPDATE :似乎是PNG和JPEG格式的问题,因为以BMP格式保存时, p>

UPDATE: It seems to be a problem with PNG and JPEG format, because the line works while saving in BMP format.

推荐答案

BMP文件保存是内置的,和IIRC .PGM一样,其他都由第三方库提供,取决于您的操作系统。

BMP file saving is built-in, as is IIRC .PGM, the others are provided by 3rd party libs depending on your OS.

您自己构建了openCV吗?什么操作系统?

Did you build openCV yourself? What OS?

这篇关于OpenCV写入文件时出现未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆