Advertisement
juanchopanza

OpenCV camera example

Apr 23rd, 2012
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <opencv/cv.h>
  2. #include <opencv/highgui.h>
  3. #include <iostream>
  4.  
  5. int main(int, char**)
  6. {
  7.  
  8.   cv::VideoCapture cap(0); // open the default camera
  9.  
  10.   if(!cap.isOpened())  { // check if we succeeded
  11.     std::cout << "Camera not open!\n";
  12.     return -1;
  13.   }
  14.  
  15.   cv::namedWindow("Camera",1);
  16.   cv::Mat frame;
  17.  
  18.   while (true) {
  19.  
  20.     cap >> frame; // get a new frame from camera
  21.     cv::imshow("Camera", frame);
  22.     if(cv::waitKey(30) >= 0) break;
  23.  
  24.   }
  25.  
  26.   return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement