我已經成功地檢測從網絡攝像頭捕捉的面,但是,我已經發布的我的代碼唯一相關的部分捕獲約35-40幀,應用程序崩潰後,_Image
是一類我已經實施。應用程序崩潰網絡攝像頭幀
_Image *Obj;
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
if (!capture)
{
fprintf(stderr, "\n\n---ERROR: capture is NULL---\n");
}
IplImage * frame = cvQueryFrame(capture);
// Show the image captured from the camera in the window and repeat
while (1)
{
frame = cvQueryFrame(capture);
if (!frame) {
fprintf(stderr, "ERROR: Webcam frame is null...Unexpected Error - Exiting");
getchar();
exit(0);
}
Obj = new _Image(frame);
if(Obj==0)
{
fprintf(stderr, "\nERROR: Out of Memory!!\n");
cvReleaseImage(&frame);
cvDestroyAllWindows();
// Release the capture device
cvReleaseCapture(&capture);
exit(0);
}
flag = Obj->detect_face_in_image();
if(flag!=0)
{
Obj->add_frame_name();
Obj->webcam_reader(*Obj);
}
// Do not release the frame!
delete Obj;
cvNamedWindow("WEBCAM", CV_WINDOW_AUTOSIZE);
cvShowImage ("WEBCAM", frame);
if ((cvWaitKey(10)) == 27)
{
cvReleaseImage(&frame);
cvDestroyAllWindows();
// Release the capture device
cvReleaseCapture(&capture);
break;
}
}
但是我沒有得到這樣的崩潰,如果改變我的代碼有點播放AVI文件,這僅與網絡攝像頭髮生。我得到了Windows XP send or dont send error report
,崩潰前沒有具體的錯誤信息。
你不提什麼樣的* *崩潰,你正目睹(訪問衝突,堆棧溢出,等...),也沒有下落,在此代碼發生崩潰。你在調試器中看到了什麼? – Johnsyweb
該程序剛剛崩潰,就像你有時從任務管理器中結束任務一樣......沒有具體的方法來找出確切的原因......我應該如何在這裏使用調試器? –
@Johnsyweb - 當我刪除'刪除Obj'的問題得到解決,但不會導致內存泄漏,如何對付這個? –