下面这个程序在释放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;
}
#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;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货