title: OpenCV - unhandled exception in Videocapture
body: <p>I recently installed OpenCV 2.4.7 and configured it to my Visual Studio 2010 Ultimate ide... i even tested a code to display an image...</p>
  
  <pre><code>#include "opencv2/highgui/highgui.hpp"
  #include "iostream"
  
  using namespace cv;
  using namespace std;
  
  int main()
  {
      Mat im = imread("d:/lena.jpg");
      if (im.empty()) 
      {
          cout &lt;&lt; "Cannot load image!" &lt;&lt; endl;
          return -1;
      }
      imshow("Image", im);
      waitKey(0);
  }
  </code></pre>
  
  <p>and it works but when I try to use the videocapture code given <a href="http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture" rel="nofollow">here</a>, it gives an error.. </p>
  
  <pre><code>#include "opencv2/opencv.hpp"
  
  using namespace cv;
  
  int main(int, char**)
  {
      VideoCapture cap(0); // open the default camera
      if(!cap.isOpened())  // check if we succeeded
          return -1;
  
      Mat edges;
      namedWindow("edges",1);
      for(;;)
      {
          Mat frame;
          cap &gt;&gt; frame; // get a new frame from camera
          cvtColor(frame, edges, CV_BGR2GRAY);
          GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
          Canny(edges, edges, 0, 30, 3);
          imshow("edges", edges);
          if(waitKey(30) &gt;= 0) break;
      }
      // the camera will be deinitialized automatically in VideoCapture destructor
      return 0;
  }
  </code></pre>
  
  <blockquote>
    <p>Unhandled exception at 0x75dc812f in myNewOpenCv1.exe: Microsoft C++ exception: cv::Exception at memory location 0x0019f6d8</p>
  </blockquote>
  
  <p>i don't know whether its a problem with the installation or not. I'm very new to OpenCV and don't know much so if anyone who is well used to this can fix this error for me and also give me an explanation as to why it happened and a guidance in this would be great.</p>
  
  <p>Hopefully waiting for your answers
  - Jonathan - </p>