24 lines
669 B
Python
24 lines
669 B
Python
|
# -*- coding: utf-8 -*-
|
||
|
# @Time : 2024/4/22 11:31
|
||
|
# @Author : len
|
||
|
# @File : 识别二维码内容.py
|
||
|
# @Software: PyCharm
|
||
|
# @Comment :
|
||
|
|
||
|
from PIL import Image
|
||
|
from pyzbar.pyzbar import decode
|
||
|
|
||
|
# 图片路径(替换成您的图片路径,确保路径正确,支持中文路径)
|
||
|
image_path = r'D:\Waste\嵌入式\数据集\二维码\颜色分类\qr\vlcsnap-2024-04-11-18h44m11s9493.jpg'
|
||
|
|
||
|
# 使用Pillow读取图片
|
||
|
image = Image.open(image_path)
|
||
|
|
||
|
# 使用pyzbar解码二维码
|
||
|
decoded_objects = decode(image)
|
||
|
|
||
|
# 打印识别到的二维码数据
|
||
|
for obj in decoded_objects:
|
||
|
print('类型:', obj.type)
|
||
|
print('数据:', obj.data.decode('utf-8'), '\n')
|