即使在简单的程序中也会出现内存错误和异常。调试中的代码块 + mingw - SIGSEGV,调用堆栈 - user32.dll。运行时崩溃并出现 0xc0000005 错误。VC 也因未处理的异常而崩溃。
#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <iostream>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
CvCapture* capture = cvCreateCameraCapture(CV_CAP_ANY); //cvCaptureFromCAM( 0 );
assert( capture );
IplImage* frame=0;
cvNamedWindow("capture", CV_WINDOW_AUTOSIZE);
int counter=0;
char filename[512];
while(true){
frame = cvQueryFrame( capture );
cvShowImage("capture", frame);
char c = cvWaitKey(33);
if (c == 27) {
break;
}
}
cvReleaseCapture( &capture );
cvDestroyWindow("capture");
return 0;
}