我已经成功地检测从网络摄像头捕捉的面,但是,我已经发布的我的代码唯一相关的部分捕获约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'的问题得到解决,但不会导致内存泄漏,如何对付这个? –