Hi! I'm new here.
I have some problems using Visual studio 2010 and Opencv 2.4.9.
I'm trying to capture video from file...when I do the debug I haven't any error but I can't open the video and I have these messages:
First-chance exception at 0x779d1d05 (ntdll.dll) in prova_video.exe: 0xC0000005: Access violation reading location 0x0263ffff.
First-chance exception at 0x75dbc42d (KernelBase.dll) in prova_video.exe: 0x00FF00FF: 0xff00ff.
I searched on Internet but I really don't know how to fix this problem.
This is the code:
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
usingnamespace cv;
usingnamespace std;
int main(int argc, char* argv[])
{
VideoCapture cap("C:/Users/ILARIA/Documents/Municipio.avi"); // open the video file for reading
if ( !cap.isOpened() ) // if not success, exit program
{
cout << "Cannot open the video file" << endl;
return -1;
}
//cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Frame per seconds : " << fps << endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
while(1)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read the frame from video file" << endl;
break;
}
imshow("MyVideo", frame); //show the frame in "MyVideo" window
if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}