我正在使用OpenCV函数:cvExtractSURF
但我发现了一个主要的内存泄漏。有没有人成功实施此次通话?
我的代码如下:
IplImage *cvImage = [self CreateIplImageFromUIImage:image grayscale:YES];
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq *objectKeypoints = 0;
//CvSeq *objectDescriptors = 0;
CvSURFParams params = cvSURFParams(self.hessianThreshold, 0);
double tt = (double)cvGetTickCount();
//Extract the features
cvExtractSURF( cvImage, 0, &objectKeypoints, NULL, storage, params, 0);
tt = (double)cvGetTickCount() - tt;
//NSLog(@"%d features found in %gms seconds\n", objectKeypoints->total, tt/(cvGetTickFrequency()*1000.));
cvReleaseImage(&cvImage);
cvReleaseMemStorage(&storage);
任何可能泄漏的想法?当我注释掉这一行:
cvExtractSURF( cvImage, 0, &objectKeypoints, NULL, storage, params, 0);
没有发生泄漏。
答案 0 :(得分:3)
函数cvExtractSURF创建一个CvSURFPoint类型的对象列表,并在objectKeypoints中放置一个指向它的指针。你必须释放它。
添加电话......
cvRelease((void **)&objectKeypoints);