当前位置:网站首页>Opencv4 QR code recognition test
Opencv4 QR code recognition test
2022-04-23 03:36:00 【Crispy eggplant strips】
OpenCV4 Two dimensional code recognition is introduced , Function is cv::QRCodeDetector
, It's relatively simple to use , This paper is attached with c++ edition OpenCV QR code recognition program .
Measured results :
Original picture :
design sketch :
The recognition result is :123456789OCR
#include "opencv2/opencv.hpp"
#include <iostream>
int main(int argc, char* argv[])
{
// Image Reading 、 Preprocessing
cv::Mat img = cv::imread("1.png");
cv::Mat gray;
cv::cvtColor(img, gray, cv::COLOR_RGB2GRAY);
// Instantiate the class of QR code
cv::QRCodeDetector QRdetecter;
std::vector<cv::Point> list;
cv::Mat QR_img;
// Perform QR code recognition
bool b = QRdetecter.detect(gray, list);
//if (b)
//{
// string str = QRdetecter.decode(gray, list);
// std::cout <<" Recognition result :"<< str << std::endl;
//}
std::string str = QRdetecter.detectAndDecode(gray, list, QR_img);
std::cout <<" Recognition result :"<< str << std::endl;
// Draw QR code area
for (int j = 0; j < list.size(); j++)
{
if (j == 3)
line(img, list[j], list[0], cv::Scalar(0, 255, 0), 2);
else
line(img, list[j], list[j + 1], cv::Scalar(0, 255, 0), 2);
}
// Show
cv::namedWindow("result_img", 0);
imshow("result_img", img);
if (QR_img.data)
{
cv::namedWindow("QR_img", 0);
imshow("QR_img", QR_img);
}
cv::waitKey(0);
return 0;
}
版权声明
本文为[Crispy eggplant strips]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220602451561.html
边栏推荐
- Applet - more than two pieces of folding and expansion logic
- Identifier and type conversion
- Problem a: face recognition
- Three column layout (fixed width on both sides in the middle and fixed width on both sides in the middle)
- The query type of MySQL is very inefficient.
- What to pay attention to when writing the first code
- 7-2 Tushare
- Unity knowledge points (common core classes)
- 2021-08-31
- 2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
猜你喜欢
Super easy to use [general excel import function]
. net webapi access authorization mechanism and process design (header token + redis)
Download and configuration of idea
JS - accuracy issues
A sword is a sword. There is no difference between a wooden sword and a copper sword
Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)
Learn about I / O flow and file operations
Common net HP UNIX system FTP server listfiles returns null solution.
变量、常量、运算符
Design and implementation of redis (3): persistence strategy RDB, AOF
随机推荐
浅学一下I/O流和File类文件操作
SQL learning record
JS - accuracy issues
Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)
Visual programming - Experiment 1
Batch download of files ---- compressed and then downloaded
Problem B: small challenge
Generate QR code through zxing
Redis(17) -- Redis缓存相关问题解决
Optimization of especially slow startup in idea debugging mode
If statement format flow
Supersocket is Used in net5 - command
Punch in: 4.22 C language chapter - (1) first knowledge of C language - (11) pointer
Design and implementation of redis (5): master-slave replication strategy and optimization
L3-011 direct attack Huanglong (30 points)
Alphafpld upgrade alphafold multimer
Wechat applet canvas draws a simple asymptotic color of the dashboard
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
C abstract class
Problem a: face recognition