CROP
ProjectsPDF Parser

Barcode/QR Code Detection Service

Service for detecting and extracting barcodes and QR codes from images.

Barcode/QR Code Detection Service

Service for detecting and extracting barcodes and QR codes from images.

Features

  • 🔍 Barcode detection (EAN-13, UPC-A, Code 128, etc.)
  • 📱 QR Code detection
  • 📦 Batch processing
  • 🔗 URL image support
  • 📊 Bounding box coordinates

Quick Start

Local Development

cd barcode_service
pip install -r requirements.txt

# Run service
uvicorn main:app --reload --port 8003

Service will be available at http://localhost:8003

API Endpoints

Health Check

GET /
GET /health

Single Image Detection

POST /detect
Content-Type: multipart/form-data

file: <image file>

Image from URL

POST /detect/url
Content-Type: application/json

{
  "url": "https://example.com/image.jpg"
}

Batch Detection

POST /detect/batch
Content-Type: multipart/form-data

files: <image files>

Response Format

{
  "barcodes": [
    {
      "type": "qr_code",
      "data": "part_number_12345",
      "format": "QRCODE",
      "bbox": [100.0, 200.0, 150.0, 150.0]
    }
  ],
  "count": 1
}

Deployment to GCP

Deploy to Cloud Run

cd barcode_service
./deploy.sh

Integration

Use this service to extract part numbers from barcodes/QR codes:

import requests

# Detect barcodes in image
response = requests.post(
    "http://barcode-service:8003/detect",
    files={"file": open("part_label.jpg", "rb")}
)

barcodes = response.json()["barcodes"]
for barcode in barcodes:
    part_number = barcode["data"]
    # Lookup in MongoDB or Weaviate

Libraries

  • pyzbar: Primary library for barcode/QR code detection (recommended)
  • opencv-python: Fallback for QR code detection

Supported Formats

Barcodes

  • EAN-13
  • EAN-8
  • UPC-A
  • UPC-E
  • Code 128
  • Code 39
  • ITF (Interleaved 2 of 5)
  • And more (via pyzbar)

QR Codes

  • Standard QR Code
  • Micro QR Code

On this page