Home | History | Annotate | Download | only in example_cmake
      1 #include "opencv2/core.hpp"
      2 #include "opencv2/imgproc.hpp"
      3 #include "opencv2/highgui.hpp"
      4 #include "opencv2/videoio.hpp"
      5 #include <iostream>
      6 
      7 using namespace cv;
      8 using namespace std;
      9 
     10 void drawText(Mat & image);
     11 
     12 int main()
     13 {
     14     cout << "Built with OpenCV " << CV_VERSION << endl;
     15     Mat image;
     16     VideoCapture capture;
     17     capture.open(0);
     18     if(capture.isOpened())
     19     {
     20         cout << "Capture is opened" << endl;
     21         for(;;)
     22         {
     23             capture >> image;
     24             if(image.empty())
     25                 break;
     26             drawText(image);
     27             imshow("Sample", image);
     28             if(waitKey(10) >= 0)
     29                 break;
     30         }
     31     }
     32     else
     33     {
     34         cout << "No capture" << endl;
     35         image = Mat::zeros(480, 640, CV_8UC1);
     36         drawText(image);
     37         imshow("Sample", image);
     38         waitKey(0);
     39     }
     40     return 0;
     41 }
     42 
     43 void drawText(Mat & image)
     44 {
     45     putText(image, "Hello OpenCV",
     46             Point(20, 50),
     47             FONT_HERSHEY_COMPLEX, 1, // font face and scale
     48             Scalar(255, 255, 255), // white
     49             1, LINE_AA); // line thickness and type
     50 }
     51