I'm using VideoCapture capture(filename); to load a video from a file. When I run the program in visual studio (release mode), it works just fine, loading the video like I would expect. When I run outside of visual studio (by double-clicking the icon in the explorer directory) the video cannot be found and the capture device returns null, even though it's the same file and paths are hardcoded and absolute.
Any ideas?
Update: Also tried using the old CvCapture* and same error.
Update 6/19:
Here's some example code.
#include "opencv2/highgui/highgui.hpp" #include <iostream> using namespace std; using namespace cv; int main(int argc, char** args) { const char* filename = "c:/testvideo.wmv"; //Check to see if we can see the file FILE* myFile = fopen(filename, "r"); if (myFile) cout<<"0: Found file"<<endl; else cout<<"0: File not found"<<endl; //First use the openCV new way of doing it VideoCapture capture1(filename); if (capture1.isOpened()) cout<<"1: Opened the video successfully"<<endl; else cout<<"1: Could not open the video"<<endl; //Second, try the old way CvCapture* capture2 = cvCaptureFromFile(filename); if (capture2) cout<<"2: Opened the video successfully"<<endl; else cout<<"2: Could not open the video"<<endl; //Pause char c; cin>>c; return 0; } In Visual Studio running in release mode I get:
0: File Found 1: Opened the video successfully 2: Opened the video successfully Running from the exe from the file system (double-clicking) I get:
0: File Found 1: Could not open the video 2: Could not open the video I only compiled once, so there's only one exe in the directory... I've also tried displaying the frames in Visual Studio, so I know it's actually really reading the video when it thinks it's open.