mi-task/test/plugins/qrcode/opencv-test.py

15 lines
307 B
Python
Raw Normal View History

import cv2
# Read the image containing a QR code
img = cv2.imread("image.png")
# Create a QR code detector
qr_decoder = cv2.QRCodeDetector()
# Detect and decode the QR code
data, bbox, _ = qr_decoder.detectAndDecode(img)
if data:
print("Decoded data:", data)
else:
print("QR code not detected.")