mi-task/test/plugins/qrcode/opencv-test.py
2025-08-18 11:06:42 +08:00

15 lines
307 B
Python
Executable File

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.")