您的位置:首页 > 运维架构

【opencv学习】关于Mat释放的问题

2014-03-07 15:18 183 查看
最近写了一个超简单的代码,但是总是有bug

int _tmain(int argc, _TCHAR* argv[])
{

Mat img_mat=imread("6.jpg");

cout<<"*****************"<<endl;

cvNamedWindow("mat",0);
imshow("mat",img_mat);
cvWaitKey();
cvDestroyWindow("mat");

cvReleaseData(&img_mat);

return 0;
}


运行后提示:Unhandled exception at at 0x77194B32 in test.exe: Microsoft C++ exception: cv::Exception at memory location 0x0100F80C.

后来看了一下mat的源代码,把

cvReleaseData(&img_mat);


改为

img_mat.release();


就好了。

原因还不清楚,有机会再细细研究吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: