title: OpenCV 2.2 Does not open Camera
body: <p>I would like to use camera and perform image processing on the input stream, but when program is executed a window appears asking 'Capture Source' after which when 'OK' or 'Apply' nothing happens.</p>
  
  <p>But if I use video file instead of camera, the program runs perfectly fine.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>int MainWindow::on_CameraOpen_triggered()
  {
  // programming done in Qt and using Opencv 2.2.
  // all the variables are defined &amp; declared in private of header file
  // there is no compilation error
  // return type of the function is 'int'
  // Following program works fine if name of video file is mentioned 
  // instead of '0' is the line below
  VideoCapture capture(0);
  
  if(!capture.isOpened())
      return 1;
  
      bool stop(false);
      double rate = capture.get(CV_CAP_PROP_FPS);
      namedWindow("Extracted Frame");
      int delayVideo = 1000/rate;
  
      while(!stop)
      {
          if(!capture.read(frame))
          {
              break;
          }
          imshow("Extracted frame", frame);
          if(waitKey(delayVideo)&gt;=0)
          {
              stop = true;
          }
      }
  
  capture.release();
  }
  </code></pre>
  
  <p>I have tried to remove the bug which was rectified at following link: 
  <a href="https://code.ros.org/trac/opencv/changeset/4400" rel="nofollow">https://code.ros.org/trac/opencv/changeset/4400</a></p>
  
  <p><a href="https://code.ros.org/trac/opencv/browser/trunk/opencv/modules/highgui/src/precomp.hpp?rev=4400" rel="nofollow">https://code.ros.org/trac/opencv/browser/trunk/opencv/modules/highgui/src/precomp.hpp?rev=4400</a></p>
  
  <p>Camera works fine on gtalk and other camera softwares.</p>
  
  <p>Kindly suggest/guide what can be done.</p>
  
  <p>Thank you very much.</p>
  
  <p>Regards,
  dbs</p>