A Python application that uses OpenCV to detect and decode QR codes in HEIC (High Efficiency Image Container) files and other common image formats.
- HEIC Support: Converts HEIC/HEIF files to OpenCV-compatible format
- Multiple QR Code Detection: Can detect and decode multiple QR codes in a single image
- Visual Feedback: Draws bounding boxes around detected QR codes with labels
- Command Line Interface: Easy-to-use CLI for batch processing
- Flexible Output: Save results to file and/or display on screen
Actuvate environment first
source .venv/bin/activate
- Clone or download this repository
- Install the required dependencies:
pip install -r requirements.txt
Or install packages individually:
pip install opencv-python numpy pillow pillow-heif
- opencv-python: Computer vision library for QR code detection
- numpy: Numerical computing library
- pillow: Python Imaging Library for image processing
- pillow-heif: HEIC/HEIF image format support for Pillow
Basic usage:
python qr_code_detector.py path/to/your/image.heic
Save result to file:
python qr_code_detector.py path/to/your/image.heic -o result.jpg
Process without displaying the result:
python qr_code_detector.py path/to/your/image.heic --no-display
from qr_code_detector import QRCodeDetector
# Create detector instance
detector = QRCodeDetector()
# Process an image
qr_data = detector.process_image(
"path/to/image.heic",
output_path="result.jpg",
display=True
)
print(f"Detected QR codes: {qr_data}")
from qr_code_detector import QRCodeDetector
detector = QRCodeDetector()
# Load image manually
image = detector.load_image("image.heic")
# Detect QR codes
qr_codes = detector.detect_qr_codes(image)
# Process results
for i, (data, points) in enumerate(qr_codes):
print(f"QR Code {i+1}: {data}")
print(f"Corner points: {points}")
# Draw QR codes on image
result_image = detector.draw_qr_codes(image, qr_codes)
- HEIC/HEIF: High Efficiency Image Container format (iPhone photos)
- JPEG/JPG: Joint Photographic Experts Group
- PNG: Portable Network Graphics
- BMP: Bitmap
- TIFF/TIF: Tagged Image File Format
- WEBP: Web Picture format
See example_usage.py
for comprehensive usage examples including:
- Processing single HEIC images
- Batch processing multiple images
- Programmatic detection and analysis
If you encounter issues with HEIC files, ensure pillow-heif
is properly installed:
pip uninstall pillow-heif
pip install pillow-heif
If image display doesn't work properly on macOS, try:
pip uninstall opencv-python
pip install opencv-python-headless
- Ensure QR codes are clearly visible and not too small
- Try adjusting image brightness/contrast
- Verify the QR code is not damaged or distorted
The detector will:
- Print the number of QR codes found
- Display the decoded data for each QR code
- Show the image with QR codes highlighted (if display enabled)
- Save the annotated image to file (if output path provided)
positional arguments:
image_path Path to the input image file
optional arguments:
-h, --help Show help message and exit
-o OUTPUT, --output OUTPUT
Path to save the result image
--no-display Do not display the result image
This project is open source and available under the MIT License.