05/14 끝
This commit is contained in:
44
Homework/QRCode/main.cpp
Normal file
44
Homework/QRCode/main.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <iostream>
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int main() {
|
||||
VideoCapture cap(0);
|
||||
|
||||
if (!cap.isOpened()) {
|
||||
cerr << "Camera open failed!" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QRCodeDetector detector;
|
||||
|
||||
Mat frame;
|
||||
while (true) {
|
||||
cap >> frame;
|
||||
if (frame.empty())
|
||||
break;
|
||||
|
||||
vector<Point> points;
|
||||
Mat straightQRCode;
|
||||
string info = detector.detectAndDecode(frame, points, straightQRCode);
|
||||
resize(straightQRCode, straightQRCode, Size(200, 200));
|
||||
|
||||
if (!info.empty()) {
|
||||
polylines(frame, points, true, Scalar(0, 0, 255), 2);
|
||||
putText(frame, info, Point(10, 30), FONT_HERSHEY_DUPLEX, 1, Scalar(0, 0, 255));
|
||||
imshow("QR", straightQRCode);
|
||||
}
|
||||
else {
|
||||
destroyWindow("QR");
|
||||
}
|
||||
|
||||
imshow("frame", frame);
|
||||
|
||||
if (waitKey(10) == 27)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user