当前位置:网站首页>Maixll-Dock 二维码识别
Maixll-Dock 二维码识别
2022-07-20 17:21:00 【咸鱼箘】
Maixll-Dock 二维码识别
二维码识别就不用我多说了吧
咸鱼出品,能用就行~
选用版本:v831-m2dock-maixpy3-0.5.0-20220601
二维条码/二维码(2-dimensional bar code)
用某种特定的几何图形按一定规律在平面(二维方向上)分布的黑白相间的图形记录数据符号信息的;使用若干个与二进制相对应的几何形体来表示文字数值信息,通过图象输入设备或光电扫描设备自动识读以实现信息自动处理:
它具有条码技术的一些共性:
- 每种码制有其特定的字符集;每个字符占有一定的宽度;具有一定的校验功能等。
- 同时还具有对不同行的信息自动识别功能、及处理图形旋转变化点。
image模块:find_qrcodes
一、导入模块
from maix import image
二、基本使用方法
from maix import image
x=image.find_qrcodes()
print(x)
获取外框坐标:读取 find_qrcodes() 函数返回的字典中键值为: x , y , w , h的值作为二维码外框的坐标信息(蓝色框)。 > 获取内框坐标:读取 find_qrcodes() 函数返回的字典中键值为: corners 的列表中的值作为二维码内框的坐标(绿色框)。
获取二维码信息:读取 find_qrcodes() 函数返回的字典中键值为: payload 的值作为二维码信息。
字典的键值如下所示:‘x’ , ‘y’ , ‘w’ , ‘h’ , ‘payload’ , ‘version’ , ‘ecc_level’ , ‘mask’ , ‘data_type’ , ‘eci’ , ‘corners’。
键值 | 说明 |
---|---|
x | 返回二维码的边界框的x坐标(int)。 |
y | 返回二维码的边界框的y坐标(int)。 |
w | 返回二维码的边界框的w坐标(int)。 |
h | 返回二维码的边界框的h坐标(int)。 |
payload | 返回二维码有效载荷的字符串,例如URL 。 |
version | 返回二维码的版本号(int)。 |
ecc_level | 返回二维码的ECC水平(int)。 |
mask | 返回二维码的掩码(int)。 |
data_type | 返回二维码的数据类型 |
eci | 返回二维码的ECI。ECI储存了QR码中存储数据字节的编码。 |
qrcode.corners | 返回一个由该对象的四个角组成的四个元组(x,y)的列表。四个角通常是按照从左上角开始沿顺时针顺序返回的。 |
案例:识别二维码
查看 find_qrcodes() 返回信息
from maix import display, camera
while True:
t = camera.capture()
mks = t.find_qrcodes()
print(mks) # 输出信息
display.show(t)
所获得的信息如下:是个字典哦
[{‘x’: 49, ‘y’: 41, ‘w’: 168, ‘h’: 160, ‘payload’: ‘xianyujun’, ‘version’: 1, ‘ecc_level’: 3, ‘mask’: 1, ‘data_type’: 4, ‘eci’: 0, ‘corners’: [[49, 52], [211, 41], [217, 201], [69, 196]]}]
得到了字典我们就明白下面的代码了。
识别二维码
from maix import display, camera
while True:
t = camera.capture()
mks = t.find_qrcodes()
for mk in mks:
#外框数据
X = mk['x']
Y = mk['y']
W = mk['w']
H = mk['h']
#二维码信息
string = mk['payload']
#内框数据
x1,y1 = mk['corners'][0] #访问字典的列表
x2,y2 = mk['corners'][1]
x3,y3 = mk['corners'][2]
x4,y4 = mk['corners'][3]
#画外框
t.draw_rectangle(X, Y, X + W, Y + H, color=(0, 0, 255), thickness = 2)
#打印信息
t.draw_string(int(X) , int(Y - 35) , str(string), scale = 2.0, color = (255, 0, 0), thickness = 2) #内框ID
#画内框
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)
效果图:(识别不了复杂的二维码,特别华丽的那种不行哦。)
边栏推荐
- Execution failed for task 'encountered using room': app:kaptdebugkotlin‘
- It's just a TCC distributed transaction. Is it so difficult?
- Basic usage of async function and await expression in ES6
- C语言之NULL的含义
- Problems of puts () for C language beginners
- 学习编程语言的方法、经验和教训
- 常用测试用例设计方法之边界值分析法
- 【MySQL】 insert into ... select ...
- ACL与NAT
- MySQL 啥时候用表锁,啥时候用行锁?
猜你喜欢
学习记录十六
Cbcgpcolordialog control used by BCG
Modification and use of j-vxe-table and j-popup components in jeecg
Cbcgptreectrlex control used by BCG
Aiops learning path
Share a little personal software testing experience and feelings after 13 years of work
How many identical characters are there in the MySQL query string (the query string contains a specific number of identical characters)
CAD复制命令
线段树-区间修改树
Is CSDN like this now? No one reviews it?
随机推荐
Combine pyqt5 to develop one click conversion software for office documents, and there is no need to open members to transfer files in the future
ACL与NAT
【问题解决】win服务器磁盘初始化
Modification and use of j-vxe-table and j-popup components in jeecg
VGA设计(原理说明。Verilog代码实现,仿真结果)
Strcmp() and if statement
海外APP推送(上篇):厂商通道与谷歌FCM通道的差异
Boundary value analysis of common test case design methods
H5在线CAD后台读写CAD文件
node 读取出某一个文件夹内的所有文件路径(此处会遍历所有文件夹,如有其他操作看着加就行了)
知识图谱 关系抽取有哪些方法
我的创作纪念日(2021.7.18 - 2022.7.18)
go学习笔记(一)
连续3月霸榜热销前10,建站top产品是如何炼成的?
信息化概论
正则表达式匹配所有中文字符或者带有双引号的字符
strcmp()与if语句
How Jenkins sends email, advanced test hands-on to teach you
The getsubmittedfilename() method is unavailable
Week 5 - Neural Networks and Neural Language Models