opencv视频显示很卡,很慢,内存泄露
我这线程函数是显示视频,其中每一帧我调用我的videorunhs(IplImage* img,IplImage *mo)来处理,可能是内存释放不到位,引起播放是很慢,而且内存在慢慢的增长,,,请各位看看看是哪出错了
UINT CtestDlg:: videorun(LPVOID IpParamater)
{
CtestDlg *pDlg = (CtestDlg*)IpParamater;
CString filename = ((PARAMATER*)IpParamater)->path;
CvCapture *capture = NULL;
capture=cvCaptureFromAVI(filename);
int framesum = (int) cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_COUNT );
int numfrm = 0;
IplImage* frame =NULL;
IplImage * newframe= NULL;
IplImage *mo = NULL;
newframe=cvCreateImage(cvSize(frame->width, frame->height), IPL_DEPTH_8U,1);
while(numfrm < framesum)
{
numfrm ++;
frame = cvQueryFrame(capture);
mo = cvLoadImage("..\\resource\\mo.bmp",1);
newframe = cvCloneImage (frame);
pDlg->videorunhs(newframe,mo); //此处调用函数
if(cvWaitKey(1)==27||stop==0)
return 0;
Sleep(40);
}
cvReleaseCapture(&capture);
return 0;
}
void CtestDlg::videorunhs(IplImage* img,IplImage *mo)
{
if(img)
{
........
...........
............////由于太长省略处理具体过程,主要就是把img处理后全部放在mo中,这期间没有任何cvcreate和cvRelease操作
cvReleaseImage(&img);
cvReleaseImage(&mo);
}
else
{
}
}
不知是哪里出错还请,各位多多指教.....