VIdeoCapture can't read frame and get method returns zero for everything.

asked 2016-03-20 04:30:54 -0600

rajat.koner gravatar image

Hi, I am using OpenCV 3.1 in Ubuntu 14.4 with eclipse CDT.I i just tried to open a video file and read frame and some of its property.VideoCapture open the file but didnt produce any output.No other window for imshow. Please help if there is any problem with installation or anything.

Below is the sample code of me:

VideoCapture cap("/home/rajat/Desktop/videos/street.mp4"); // open the video file for reading

if ( !cap.isOpened() ) // if not success, exit program { cout << "Cannot open the video file" << endl; return -1; }

double fps = cap.get(CAP_PROP_FPS); //get the frames per seconds of the video cout << "Frame per seconds : " << fps << endl;

Mat frame; cap.read(frame); if(!cap.read(frame)){ cout<<"Unable to load frame from video.stream"<<endl; return="" 1;="" }="" imshow("video",frame);="" if(waitkey(1)="=27){" return="" 2;="" }<="" p="">

The out put:

image description

edit retag flag offensive close merge delete