Quickstart: Detect and decode QR codes
mainFor most use cases, you only need to instantiate QReader once and call detect_and_decode. This method returns a tuple containing the decoded strings for every QR code found. Note that some entries may be None if a QR was detected but could not be successfully decoded.
from qreader import QReader
import cv2
# Create a QReader instance (do this once to avoid reloading the model)
qreader = QReader()
# Load image and convert to RGB
image = cv2.cvtColor(cv2.imread("path/to/image.png"), cv2.COLOR_BGR2RGB)
# Get the decoded QR data
decoded_text = qreader.detect_and_decode(image=image)
# decoded_text is a tuple, e.g., ('Data 1', None, 'Data 2')from qreader import QReader
import cv2
qreader = QReader()
image = cv2.cvtColor(cv2.imread("path/to/image.png"), cv2.COLOR_BGR2RGB)
decoded_text = qreader.detect_and_decode(image=image)