I'm trying to use Opencv to capture video from a webcam.
I have the following code
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <cstdio>
#include <iostream>
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap;
}
Which causes the program to terminate with an error
Process terminated with status -1073741510 (0 minutes, 34 seconds)
I'm wondering if I have not installed opencv correctly on codeblocks
Note that when I use this program instead, everything works fine
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
if ( !capture )
{
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
IplImage* frame = cvQueryFrame( capture );
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
while ( 1 )
{
frame = cvQueryFrame( capture );
if ( !frame )
{
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
cvShowImage( "mywindow", frame );
if ( (cvWaitKey(10) & 255) == 27 )
break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
EDIT
changing the headers to hpp files also produces the same problem
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <cstdio>
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap;
cap.open(1);
return 0;
}