I am very new to OpenCV. I downloaded and installed Open CV according to the instructions in the link https://rangadabarera.wordpress.com/opencv-with-visual-studio/ . My requirement is to create a video library that can be used to replace the existing video library that uses Video For Windows(VFW). I am trying to write a sample code to open and read an avi file. I added the following libraries "opencv_core220.lib opencv_highgui220.lib opencv_video220.lib opencv_ffmpeg220.lib". The code i have written looks like as follows
include <iostream>
include "opencv2/opencv.hpp"
include "opencv2/highgui/highgui_c.h"
include "opencv2/highgui/highgui.hpp"
using namespace std; using namespace cv; int main() { string filename ("C:\ADAS_AHBC_201046_002.avi") ;
VideoCapture input;
bool status = input.open( filename );
if (!input.isOpened()) return 0;
int frameCount = input.get(CV_CAP_PROP_FRAME_COUNT);
}
But while running the code, i am getting an exception with the following text Unhandled exception at 0x00905a4d in aviread.exe: 0xC0000005: Access violation. The value of the obj and referance count fields within the VideoCapture object seems to be 0
I tried another version like as follows and the output is the same int main() { string filename ("C:\ADAS_AHBC_201046_002.avi") ;
VideoCapture input = VideoCapture( filename );
//bool status = input.open( filename );
if (!input.isOpened()) return 0;
int frameCount = input.get(CV_CAP_PROP_FRAME_COUNT);
}
But when i tried to to read from a camera, it seems like not throwing any error. The code is as follows int main() { string filename ("C:\ADAS_AHBC_201046_002.avi") ;
VideoCapture input = VideoCapture( 0 );
//bool status = input.open( filename );
if (!input.isOpened()) return 0;
int frameCount = input.get(CV_CAP_PROP_FRAME_COUNT);
} While debugging this code, my lap's camera is getting invoked. Can you please help me understand as what is wrong with what i am doing.
Thanks AJAI