title: Opencv cannot access my webcam
body: <p>I have trouble with accessing webcam using opencv 2.4.3.</p>
  
  <p>My System:</p>
  
  <p>Hp Probook 4530s - HP Fixed HD Webcam</p>
  
  <p>Ubuntu 12.10</p>
  
  <p>OpenCV 2.4.3</p>
  
  <p>İf I want to capture my built-in camera i get ERROR: capture is NULL</p>
  
  <p>I'm using <a href="http://opencv.willowgarage.com/wiki/CameraCapture" rel="nofollow noreferrer">http://opencv.willowgarage.com/wiki/CameraCapture</a> sample code.</p>
  
  <p>Sample code is:</p>
  
  <pre><code>#include "cv.h" 
  #include "highgui.h" 
  #include &lt;stdio.h&gt;  
  // A Simple Camera Capture Framework 
  int main() {
  CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
  if ( !capture ) {
   fprintf( stderr, "ERROR: capture is NULL \n" );
   getchar();
   return -1;
  }
  // Create a window in which the captured images will be presented
  cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
  // Show the image captured from the camera in the window and repeat
  while ( 1 ) {
   // Get one frame
   IplImage* frame = cvQueryFrame( capture );
   if ( !frame ) {
     fprintf( stderr, "ERROR: frame is null...\n" );
     getchar();
     break;
   }
   cvShowImage( "mywindow", frame );
   // Do not release the frame!
   //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
   //remove higher bits using AND operator
   if ( (cvWaitKey(10) &amp; 255) == 27 ) break;
  }
  // Release the capture device housekeeping
  cvReleaseCapture( &amp;capture );
  cvDestroyWindow( "mywindow" );
  return 0;
  }
  </code></pre>
  
  <p>I also tried with <strong>xawtv -hwscan</strong> using typing terminal. I get this output:</p>
  
  <pre><code>looking for available devices
  port 129-144
  
  type : Xvideo, image scaler
  name : Intel(R) Textured Video`
  
  
  /dev/video0: OK    
               [ -device /dev/video0 ]
  type : libv4l
  
  name : HP HD Webcam [Fixed]
  
  flags:  capture
  </code></pre>
  
  <p>then I can access my webcam typing <strong>xawtv video0</strong>. I think I have no trouble with my webcam. 
  I have trouble with opencv.</p>