1 | initial version |
C++:
#include "opencv2/opencv.hpp" using namespace cv; int main(int argc, char** argv) { VideoCapture cap; // open the default camera, use something different from 0 otherwise; // Check VideoCapture documentation. if(!cap.open(0)) return 0; for(;;) { Mat frame; cap >> frame; if( frame.empty() ) break; // end of video stream imshow("this is you, smile! :)", frame); if( (waitKey() & 255) == 27 ) break; // stop capturing by pressing ESC } // the camera will be closed automatically upon exit // cap.close(); return 0; }
2 | No.2 Revision |
C++:
#include "opencv2/opencv.hpp" using namespace cv; int main(int argc, char** argv) { VideoCapture cap; // open the default camera, use something different from 0 otherwise; // Check VideoCapture documentation. if(!cap.open(0)) return 0; for(;;) { Mat frame; cap >> frame; if( frame.empty() ) break; // end of video stream imshow("this is you, smile! :)", frame); if((waitKey() & 255)waitKey(1) == 27 ) break; // stop capturing by pressing ESC } // the camera will be closed automatically upon exit // cap.close(); return 0; }
3 | No.3 Revision |
C++:
#include "opencv2/opencv.hpp" using namespace cv; int main(int argc, char** argv) { VideoCapture cap; // open the default camera, use something different from 0 otherwise; // Check VideoCapture documentation. if(!cap.open(0)) return 0; for(;;) { Mat frame; cap >> frame; if( frame.empty() ) break; // end of video stream imshow("this is you, smile! :)", frame); if(waitKey(1)waitKey(10) == 27 ) break; // stop capturing by pressing ESC } // the camera will be closed automatically upon exit // cap.close(); return 0; }