1. 程式人生 > >新手學習opencv十:記憶體洩露

新手學習opencv十:記憶體洩露

//1.opencv讀取攝像頭

1. CvCapture* m_pCapture = cvCreateCameraCapture(VideoPath);  

2. CvReleaseCapture(&m_pCapture); 

//2.Directshow中捕獲攝像頭

3. CCameraDS m_CamDS;

4. m_CamDS.OpenCamera(0, false, 320, 240))

5. m_CamDS.CloseCamera();

6. //3.讀取視訊檔案

7. CvCapture* m_pCapture = cvCreateFileCapture(VideoPath)

8. cvReleaseCapture(&m_pCapture);

//4.讀取圖片檔案

IplImage* src = cvLoadImage("1001.jpg");

cvReleaseImage(&src);

//5.視窗控制代碼

cvNamedWindow("showImage");

cvDestroyWindow("showImage");

//6.mfc

CDC* pDC = GetDlgItem(ID)->GetDC();

ReleaseDC( pDC );//釋放CDC類的指標

CvvImage cimg;

cimg.CopyOf( img );   

//6.用完cimg

cimg.DrawToHDC( hDC, &rect );

cimg.Destroy();

//7.建立影象

9. IplImage* subImg=cvCreateImage( cvSize((img->width)*scale,(img->height)*scale), 8, 3 ); 

10. cvReleaseImage(&subImg);

//8.建立矩陣

11. CvMat *tempMat=cvCreateMat((img->width)*scale,(maxFace->height)*scale,CV_MAKETYPE(image->depth,image->nChannels)); 

12. CvReleaseMat(&tempMat);

13.//9.建立矩陣記憶體

14. CvMemStorage* m_storage=cvCreateMemStorage(0); 

15. CvReleaseMemStorage(&m_storage);