Tuesday, 19 February 2013

Program to open your Web Cam using Open Cv Programming:

We previously wrote a program to load an image(Link) using open computer vision now let us see how to capture image from your webcam.



///////////////////////////////////  C LIBRARIES/////////////////
int main(int argc,char* argv){ 
CvCapture* capWebcam;                /// we will assign web cam to this later
 IplImage* webcam_img; char charchecksEnter;                // enter closes the program capWebcam = cvCaptureFromCAM(0); // for mutiple it will be 0 and 1 and so on......///
if(capWebcam == NULL ){  
printf("Error: capturing is NULL. \n"); 
 return(-1);                    /////**** Exit programme ***/////////
 webcam_img = cvQueryFrame(capWebcam);           /// assigning webcam_img to continues
                                                                                        ///  frames of images from web cam   ///
  if(webcam_img == NULL){ 
  printf("Error:frame is NULL\n");

charchecksEnter = cvWaitKey(10);   // waits for 10 ms. // 
if(charchecksEnter == 13)break;      // when enter key pressed. Program Breaks.. //

ENjoy.. :D