这是我的代码:
void Init() // For the first frame.
{
Mat in=cv::imread("img1.jpg");
SIFT* s=NULL;
vector< cv::KeyPoint > key;key.clear();
Mat* descriptors=NULL;
_CrtMemState Sh1,Sh2,Sh_Diff;
_CrtMemCheckpoint(&Sh1);
s = new SIFT();
descriptors = new Mat();
(*s)(in, Mat(), key, *descriptors);
delete s;
_CrtMemCheckpoint(&Sh2);
_CrtMemDifference(&Sh_Diff, &Sh1, &Sh2);
_CrtMemDumpAllObjectsSince(&Sh_Diff);
GetKCent(*descriptors);key.clear();
mask=cv::Scalar(0);
mask(selection)=cv::Scalar(255);
Mat mask(in.rows,in.cols,CV_8U);
s=new SIFT();
if (descriptors!=NULL) delete descriptors;
descriptors = new Mat();
(*s)(in,mask,key,*descriptors);
delete s;
}
程序执行此行时出现内存不足错误
(*s)(in,mask,key,*descriptors);
它是第二个 sift::operator()。我认为内存可能会泄漏。谁能帮我?