title: OpenCV VideoCapture not working outside Visual Studio
body: <p>I'm using <code>VideoCapture capture(filename);</code> 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.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>Update:</strong> Also tried using the old CvCapture* and same error.</p>
  
  <p><strong>Update 6/19:</strong></p>
  
  <p>Here's some example code. </p>
  
  <pre><code>#include "opencv2/highgui/highgui.hpp"
  #include &lt;iostream&gt;
  
  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&lt;&lt;"0: Found file"&lt;&lt;endl;
      else
          cout&lt;&lt;"0: File not found"&lt;&lt;endl;
  
      //First use the openCV new way of doing it
      VideoCapture capture1(filename);
  
      if (capture1.isOpened())
          cout&lt;&lt;"1: Opened the video successfully"&lt;&lt;endl;
      else
          cout&lt;&lt;"1: Could not open the video"&lt;&lt;endl;
  
      //Second, try the old way
      CvCapture* capture2 = cvCaptureFromFile(filename);
      if (capture2)
          cout&lt;&lt;"2: Opened the video successfully"&lt;&lt;endl;
      else
          cout&lt;&lt;"2: Could not open the video"&lt;&lt;endl;
  
      //Pause
      char c;
      cin&gt;&gt;c;
  
      return 0;
  }
  </code></pre>
  
  <p>In Visual Studio running in release mode I get: </p>
  
  <pre><code>0: File Found
  1: Opened the video successfully
  2: Opened the video successfully
  </code></pre>
  
  <p>Running from the exe from the file system (double-clicking) I get:</p>
  
  <pre><code>0: File Found
  1: Could not open the video
  2: Could not open the video
  </code></pre>
  
  <p>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.</p>