cannot able to open video file in videocapture [closed]

asked 2015-02-02 00:19:37 -0600

jamesnzt gravatar image

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); 
}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by jamesnzt
close date 2015-02-02 23:25:44.719647

Comments

1

Can you start by changing string filename = "1.mp4"; to an absolute path at first that is not the root folder? Some systems do not allow software to write in root folders but they do allow writing in subroot folders. For example use E:\\test\\test.jpg.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-02 04:40:17 -0600 )edit
1

It works. Thanks @StevenPuttemans I specified the file as "/home/user/Desktop/1.MP4" in fedora.The problem is the case-sensitive in specifying filename. the extension is 1.MP4 and typed it as 1.mp4.

jamesnzt gravatar imagejamesnzt ( 2015-02-02 23:24:47 -0600 )edit

Yes for any linux based system an uppercase extension is different from a lowercase extension. Glad you got it figured out!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-03 02:09:14 -0600 )edit