Tim
Tim

Reputation: 834

OpenCV Video capture from file won't open successfully

I've written this in C++ (VS2012) using the OpenCV library (2.4.6).

#include <opencv2\opencv.hpp>
#include <opencv2\highgui\highgui.hpp>    
int main(){
    Mat image;
    VideoCapture cap;
    cap.open("test.avi");
    if(!cap.isOpened()){
        cout<< "Capture not open \n";
        cin.get();
    }
    cvNamedWindow("Video Output");
    while(1){
        cap >> image;
        imshow("Video Output",image);
        waitKey(30);
    }
}

Running it, the video capture fails to open. test.avi is located in the same directory as the executable, and running it ind Debug/Release/outside the IDE makes no difference. The OpenCv DLLs and the video file are here: https://www.dropbox.com/sh/16c04d97iw90gtk/88fQ4BLbfl#/ What could I be doing wrong?

EDIT: As seen in questions on the OpenCV Q&A site, I've copied the opencv_ffmpeg DLL to the folder with my executable. Now it only works outside the IDE (VS2012)

Upvotes: 6

Views: 7938

Answers (1)

Michele
Michele

Reputation: 386

You should copy the opencv_ffmpeg DLL in your targetDir, in this case the Debug executable folder, other than the Release one

Upvotes: 9

Related Questions