Skip to content

mohammeddtariq/Barcode-QrCodeScanner

 
 

Repository files navigation

Barcode & QR Code Detector

A real-time barcode and QR code detection system built with YOLOv8 and ZXing-CPP. It detects codes from a live webcam feed, decodes them, and automatically looks up product information from multiple online databases — no specialized scanning hardware needed.


How it works

The system runs a multi-stage pipeline:

  1. Detection — YOLOv8 (Small) finds and localizes barcodes and QR codes in the webcam frame with bounding boxes
  2. Decoding — ZXing-CPP reads the content of the detected code
  3. Product lookup — the decoded value is queried against 5 product databases to retrieve item information
  4. Visual feedback — color-coded results on screen:
    • 🟢 Green — detected, decoded, and product found
    • 🟠 Orange — decoded but product not in database
    • 🔴 Red — detected but couldn't decode

Model

  • Architecture: YOLOv8-Small (CSPDarknet backbone, PANet neck, 3 detection heads)
  • Parameters: ~11.1M trainable
  • Input size: 640×640
  • Classes: 2 (barcode, qrcode)
  • Pre-trained on: COCO, fine-tuned on a custom dataset
  • Training: 30 epochs, AdamW optimizer, batch size 16, AMP enabled

Dataset

  • 325 barcode images + 275 QR code images
  • 80/20 train/validation split
  • Augmentations: rotation (±5°), perspective transform, HSV color jitter

Detection scales

The model uses three detection heads to handle different distances:

  • 80×80 feature map → small/distant codes
  • 40×40 feature map → medium distance
  • 20×20 feature map → close-range codes

Product databases queried

  • Open Food Facts (World)
  • Open Food Facts (Egypt)
  • Open Beauty Facts
  • Open Pet Food Facts
  • Open Products Facts

Challenges we solved

  • Lighting variability — handled with HSV augmentation during training
  • Viewing angle — perspective transformation augmentation lets it handle codes up to ~±20° off-axis
  • Multiprocessing on Windows — set DataLoader workers=0 to fix PicklingError in Jupyter
  • Decode failures — three-tier color feedback so partial detections are still useful

Tech

  • Python 3
  • YOLOv8 (Ultralytics)
  • ZXing-CPP for barcode/QR decoding
  • OpenCV for webcam capture and visualization
  • Open Food/Beauty/Pet Food/Products Facts APIs

Team

Mohammed Tariq, Mazen Abdallah, Malak Elhawary, Maryam Hatem, Ahmed Deaiy, Marvel Fady, Youssef Nashaat

About

This project implements an intelligent real-time Barcode and QR Code detection and recognition system using deep learning. The system combines YOLOv8 object detection with ZXing-CPP barcode decoding.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages