반응형
    
    
    
  | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /** @file videocapture_basic.cpp @brief A very basic sample for using VideoCapture and VideoWriter @author PkLab.net @date Aug 24, 2016 */ #include <opencv2/opencv.hpp> #include <iostream> #include <stdio.h> using namespace cv; using namespace std; int main(int, char**) {     Mat frame;     //--- INITIALIZE VIDEOCAPTURE     VideoCapture cap;     // open the default camera using default API     cap.open(0);     // OR advance usage: select any API backend     int deviceID = 0;             // 0 = open default camera     int apiID = cv::CAP_ANY;      // 0 = autodetect default API                                   // open selected camera using selected API     cap.open(deviceID + apiID);     // check if we succeeded     if (!cap.isOpened()) {         cerr << "ERROR! Unable to open camera\n";         return -1;     }     //--- GRAB AND WRITE LOOP     cout << "Start grabbing" << endl         << "Press any key to terminate" << endl;     for (;;)     {         // wait for a new frame from camera and store it into 'frame'         cap.read(frame);         // check if we succeeded         if (frame.empty()) {             cerr << "ERROR! blank frame grabbed\n";             break;         }         // show live and wait for a key with timeout long enough to show images         imshow("Live", frame);         if (waitKey(5) >= 0)             break;     }     // the camera will be deinitialized automatically in VideoCapture destructor     return 0; } | cs | 
웹캠으로부터 캡처된 영상을 보여주는 창이 보입니다. 아무 키나 누르면 실행이 중단됩니다.
반응형
    
    
    
  'Applied > OpenCV' 카테고리의 다른 글
| 이미지에 직선 긋기 (0) | 2019.04.30 | 
|---|---|
| blur 처리를 이용하는 방법, 응용 (0) | 2019.04.29 | 
| 원본 이미지에서 RGB 채널 각각 분리 및 저장 (0) | 2019.04.28 | 
| 기본 이미지 불러오기, 데이터 출력 (0) | 2019.04.23 | 
| OpenCV 설치(Visual Studio 2015, 2017) (2) | 2019.04.23 |