关于IplImage*释放的问题.

cxfirefox 2004-09-21 04:01:22
下面这个程序在释放img0和img的时候,会出现断言错误,为什么呢?
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
char* name[]={"./222.bmp","./11111.jpg"};

int main()
{
IplImage* img0;
IplImage* img;
int i;
cvNamedWindow( "image", 1 ); // create HighGUI window with name "image"

for( i = 0; i < 2; i++ )
{
img0 = cvLoadImage( name[i],-1 ); // load i-th image
img = cvCloneImage( img0 );
cvvShowImage( "image", img0 ); // show image in the window "image"
cvvWaitKey(0); // wait for key. The function has
// an event processing loop inside
cvReleaseImage( &img ); // release both images不能释放,否则会出现断言错误
cvReleaseImage( &img0 );
}

return 0;
}
...全文
702 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xindao_wang 2004-10-09
  • 打赏
  • 举报
回复
好像是OpenCV下的函数吧。好像没问题吧。
shelton 2004-10-09
  • 打赏
  • 举报
回复
试了一下,两幅图像均可正常释放. 程序应该是对的。换一下数据再试试!
syy64 2004-09-21
  • 打赏
  • 举报
回复
分步调试,看是否为空指针。
cxfirefox 2004-09-21
  • 打赏
  • 举报
回复
能说的详细些吗?怎么导致的无效的指针呢?
syy64 2004-09-21
  • 打赏
  • 举报
回复
指针无效。
cxfirefox 2004-09-21
  • 打赏
  • 举报
回复
不好意思,是cvReleaseImage( &img0 ); 不能释放img0,否则会出现断言错误,img的释放却不会造成问题,这是为什么啊?有没有可能是图片的数据问题呢?

19,469

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧