QRDet Python Library

repository·main·Indexed 41 days ago

https://github.com/eric-canas/qrdet

A Python library for the detection and segmentation of QR codes within images. It provides high-fidelity localization of QR code boundaries via the QRDetector class and its .detect() method.

Tokens
401
Snippets
2
Records
2
Agent score
3%

What's inside QRDet

  1. Use QRDetector to detect and segment QR codes

    main

    The 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 to False if you have already converted it to RGB).
    • legacy: A boolean to toggle between different detection modes (set to False for 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)
  2. Visualize detections with _plot_result

    main

    The _plot_result function is a utility used to visualize the detected QR codes by overlaying the detection results onto the original image. It accepts the input image and the detections list returned by the QRDetector.detect() method.

    from qrdet import _plot_result
    
    _plot_result(image=image, detections=detections)