반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

QRcode read in C++ 본문

[AI]/openCV

QRcode read in C++

givemebro 2020. 6. 23. 12:30
반응형
#include "opencv2/opencv.hpp"
#include<iostream>

using namespace cv;
using namespace std;

void decode_qrcode() {

	VideoCapture cap(0);

	if (!cap.isOpened()) {
		cerr << "Camera open failed!" << endl;
		return;
	}

	QRCodeDetector detector;

	Mat frame;
	while (true) {
		cap >> frame;

		if (frame.empty()) {
			cerr << "Frame load fialed!" << endl;
			break;
		}
		vector<Point> points;
		String info = detector.detectAndDecode(frame, points);

		if (!info.empty()) {
			polylines(frame, points, true, Scalar(0, 0, 255), 2);
			putText(frame, info, Point(10, 30), FONT_HERSHEY_SIMPLEX, 1, Scalar(0, 0, 255));
		}
		imshow("frame", frame);
		if (waitKey(1) == 27)
			break;
	}
}
int main() {
	decode_qrcode();
	return 0;
}

반응형

'[AI] > openCV' 카테고리의 다른 글

명함 인식 in python  (0) 2020.06.25
이미지 변형 in python  (0) 2020.06.24
opencv install in python  (0) 2020.06.23
detect workers in C++  (0) 2020.06.23
adaptiveThreshold  (0) 2020.06.23
binarization  (0) 2020.06.23
Canny_edge  (0) 2020.06.23
sobel_edge  (0) 2020.06.23
Comments