Use QRDetector to detect and segment QR codes
mainThe QRDetector class is the primary interface for detecting and segmenting QR codes in images. You can instantiate it and call the .detect() method to process an image.
When calling .detect(), you can specify:
image: The input image array.is_bgr: A boolean indicating if the input image is in BGR format (set toFalseif you have already converted it to RGB).legacy: A boolean to toggle between different detection modes (set toFalsefor the modern detection pipeline).
The method returns a list of detections containing the segmentation and location data for the QR codes found.
import cv2
from qrdet import QRDetector
detector = QRDetector()
# Load image and convert to RGB
image = cv2.cvtColor(cv2.imread('path/to/image.jpg'), code=cv2.COLOR_BGR2RGB)
# Perform detection
detections = detector.detect(image=image, is_bgr=False, legacy=False)