当前位置:网站首页>V831 - QR code recognition
V831 - QR code recognition
2022-07-18 17:34:00 【Me and nano】
V831
List of articles
Preface
A qualified camera , It must be able to recognize QR code .
One 、 QR code recognition character
#!/usr/bin/python3
from maix import display, camera
while True:
t = camera.capture()
mks = t.find_qrcodes()
for mk in mks:
# Outline data
X = mk['x']
Y = mk['y']
W = mk['w']
H = mk['h']
# QR code information
string = mk['payload']
# Inner frame data
x1,y1 = mk['corners'][0] # Access the list of dictionaries
x2,y2 = mk['corners'][1]
x3,y3 = mk['corners'][2]
x4,y4 = mk['corners'][3]
# Draw frame
t.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2)
# Print information
t.draw_string(int(X) , int(Y - 35) , str(string), scale = 2.0, color = (255, 0, 0), thickness = 2) # Inner frame ID
# Draw the inner frame
t.draw_line(x1, y1, x2, y2, color = (0, 255, 0), thickness = 3)
t.draw_line(x2, y2, x3, y3, color = (0, 255, 0), thickness = 3)
t.draw_line(x3, y3, x4, y4, color = (0, 255, 0), thickness = 3)
t.draw_line(x4, y4, x1, y1, color = (0, 255, 0), thickness = 3)
display.show(t)
Look directly at the code ,find_qrcodes()、 string = mk[‘payload’] these 831 All have been sealed for us , You can use it directly 
But in the later test , It is found that Chinese cannot be recognized , Will report garbled code 
So how to solve it
Two 、 Two dimensional code recognizes Chinese characters
1. Load Chinese font
image.load_freetype(path="/home/res/sans.ttf")
831 There is a built-in Chinese font , We just need to load it , then image You can display it
2. Complete code
#!/usr/bin/python3
from maix import display, camera,image
image.load_freetype(path="/home/res/sans.ttf")
while True:
t = camera.capture()
mks = t.find_qrcodes()
for mk in mks:
# Outline data
X = mk['x']
Y = mk['y']
W = mk['w']
H = mk['h']
# QR code information
string = mk['payload']
# Inner frame data
x1,y1 = mk['corners'][0] # Access the list of dictionaries
x2,y2 = mk['corners'][1]
x3,y3 = mk['corners'][2]
x4,y4 = mk['corners'][3]
# Draw frame
t.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2)
# Print information
t.draw_string(int(X) , int(Y - 35) , str(string), scale = 2.0, color = (255, 0, 0), thickness = 2) # Inner frame ID
# Draw the inner frame
t.draw_line(x1, y1, x2, y2, color = (0, 255, 0), thickness = 3)
t.draw_line(x2, y2, x3, y3, color = (0, 255, 0), thickness = 3)
t.draw_line(x3, y3, x4, y4, color = (0, 255, 0), thickness = 3)
t.draw_line(x4, y4, x1, y1, color = (0, 255, 0), thickness = 3)
display.show(t)

summary
Introduce the meaning of several key values .‘x’ , ‘y’ , ‘w’ , ‘h’ The values returned by the key values are the upper left corner of the outer frame x Coordinates and y Coordinates and the length and width of the outer frame . And key value ‘payload’ The returned value is the information of QR code .
边栏推荐
- 第一届中国数字藏品大会顺利召开
- Basic permission management of Gerrit
- 我回来了
- 如何通过客户价值分析让银行收入倍增
- PostgreSQL source code (8) xlog initialization
- 二 配置目标make menuconfig的执行过程分析
- HCIA-R&S自用笔记(9)数据转发过程、单播/多播/组播
- [actual combat] 1382- Yiwen owns your puppeter crawler application
- HCIA-R&S自用笔记(8)IP地址基础、子网掩码、子网划分
- The exit relationship between the main thread and the sub thread of the main process
猜你喜欢
随机推荐
Stc8h development (XIV): I2C drive rx8025t high-precision real-time clock chip
数据湖(十一):Iceberg表数据组织与查询
Analysis of websocket hijacking
关于cJSON的valueint超过整型范围的问题
Ceph分布式存储性能调优(六)
架构系列之标准Web系统的架构分层
The exit relationship between the main thread and the sub thread of the main process
Sewage discharge monitoring, environmental protection data acquisition instrument to help urban black and odorous water treatment
ETCD数据库源码分析——etcdserver bootstrap去除v2store
图片验证,滑块验证解决
How should both parties bear the large amount of child support after divorce
The new book is on the market | C language classic textbook supporting "exercise solutions", and the original book has been printed a total of 100000+
Flutter realizes the gradual enlargement of hero pictures and the equal proportion method of pictures. Pictures are smoothly enlarged
About the problem that the valueint of cjson exceeds the integer range
Huawei cloud x Black Lake is a system to solve all kinds of production difficulties in the manufacturing industry!
uniapp video 视频未播放完成禁止拖拽进度条快进
Using C language to realize the odd number problem of 0-10 -- Original
作用域、构造器详解
“四朵云”的较量
糖尿病遗传风险检测挑战赛-Coggle 30 Days of ML









