Ask Your Question

Revision history [back]

Okay okay, note to myself: NEVER using only the includes to define good snippets ... let me write one up:

#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;

int main(){
   VideoCapture cap(0);
   Mat new_frame;
   while(true){
      cap >> new_frame;
      if(new_frame.empty()){
         break;
      }
      imshow("camera", new_frame);
      waitKey(10);
   }
}

Simply ignore the link I have posted :D

Okay okay, note to myself: NEVER using only the includes to define good snippets ... let me write one up:

#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;

int main(){
   VideoCapture cap(0);
   Mat new_frame;
   while(true){
      cap >> new_frame;
      if(new_frame.empty()){
         break;
      }
      imshow("camera", new_frame);
      waitKey(10);
// press ESC to quit software
      if( (int)waitKey(10) == 27 ){
         break;
      }
   }
}

Simply ignore the link I have posted :D