Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cvCaptureFromCAM(x) returning NULL, tried with X = 0,1, 2.. on raspberry pi2

> #include <iostream>
> #include <opencv/cv.h>
> #include <opencv/highgui.h>
> 
> using namespace std;
> 
> char key;
> 
> int main() {
>   cvNamedWindow("Camera_Output",1);    
> //create a window     CvCapture* capture
> =cvCaptureFromCAM(0);                   // Capture using any camera, we can
> aslo use 0 as a parameter if we are
> using single camera.  if(capture ==
> NULL)         {           printf("cannot open
> camera#n");           return -1;      }
>   while(1){                            
> //creating any infinite loop for live
> streaming
>           IplImage* frame = cvQueryFrame(capture);                
> //capture image frames from camera
>       cvShowImage("Camera_Output",frame); 
> //show image frames on created window
>       key = cvWaitKey(10);                
> //Capture keyboard storke
>       if(char(key) == 27){
>                   break;      }   }       cvReleaseCapture(&capture);          
> //Release capture Image
>   cvDestroyWindow("camera_Output");    
> //Destroy Window
> 
>   return 0; }

please advice