Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cannot able to open video file in videocapture

I tried to work with video file using video capture. I tried the following program in visual studio 2013 by specifying path as E:\\1.mp4 it works. when i tried the same program in fedora it always shows "Cannot open". Please specify me where the mistake is

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace std;
using namespace cv;

int main()
{
    string filename = "1.mp4";
    VideoCapture capture(filename);
    Mat frame;

    if( !capture.isOpened() )
        {cout << "Cannot open " << endl;
    return -1;
    }
    namedWindow( "w", 1);
    for( ; ; )
    {
        capture >> frame;
        if(frame.empty())
            break;
        imshow("w", frame);
        waitKey(20); 
    }
    waitKey(0); 
}