mirror of
https://gitcode.com/gh_mirrors/es/esp32-opencv.git
synced 2025-08-14 10:40:47 +08:00
initial commit
This commit is contained in:
50
samples/cpp/example_cmake/example.cpp
Normal file
50
samples/cpp/example_cmake/example.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/videoio.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
void drawText(Mat & image);
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "Built with OpenCV " << CV_VERSION << endl;
|
||||
Mat image;
|
||||
VideoCapture capture;
|
||||
capture.open(0);
|
||||
if(capture.isOpened())
|
||||
{
|
||||
cout << "Capture is opened" << endl;
|
||||
for(;;)
|
||||
{
|
||||
capture >> image;
|
||||
if(image.empty())
|
||||
break;
|
||||
drawText(image);
|
||||
imshow("Sample", image);
|
||||
if(waitKey(10) >= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "No capture" << endl;
|
||||
image = Mat::zeros(480, 640, CV_8UC1);
|
||||
drawText(image);
|
||||
imshow("Sample", image);
|
||||
waitKey(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void drawText(Mat & image)
|
||||
{
|
||||
putText(image, "Hello OpenCV",
|
||||
Point(20, 50),
|
||||
FONT_HERSHEY_COMPLEX, 1, // font face and scale
|
||||
Scalar(255, 255, 255), // white
|
||||
1, LINE_AA); // line thickness and type
|
||||
}
|
Reference in New Issue
Block a user