Last active
January 10, 2024 21:26
-
-
Save srkiNZ84/a0a634f69584f964b8226bb452e8a034 to your computer and use it in GitHub Desktop.
Python script to decode a QR code using OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
filename = "/path/to/some_image.png" | |
image = cv2.imread(filename) | |
# Docs are here: https://docs.opencv.org/3.4/de/dc3/classcv_1_1QRCodeDetector.html | |
detector = cv2.QRCodeDetector() | |
data, vertices_array, binary_qrcode = detector.detectAndDecode(image) | |
if vertices_array is not None: | |
print("QRCode data:") | |
print(data) | |
else: | |
print("error no data") | |
# Sample output: | |
# QRCode data: | |
# otpauth://totp/Example%20Company%3AJohn.Doe%40example.com?secret=aaaabbbbcccceee1123m&issuer=Google |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment