A real-time web application that scans and decodes PDF417 barcodes on driver's licenses using computer vision and multiple barcode detection libraries.
- Camera Feed: Captures live video from selected camera
- Scan Area: Defines a centered rectangular region (70% width × 15% height) for PDF417 detection
- Multi-Library Approach: Uses multiple detection methods in priority order:
- ZXing-CPP: Primary decoder with excellent PDF417 support
- OpenCV: Backup barcode detector
- pyzbar: Fallback with multiple image preprocessing techniques
The PDF417 barcode contains ANSI-encoded driver's license data with standardized field codes:
DCS: Last NameDCT/DAC: First NameDBD: Issue DateDBA: Expiration DateDBB: Date of BirthDBC: SexDAY: Eye ColorDAU: HeightDAG: AddressDAI: CityDAJ: StateDAK: ZIP CodeDAQ: License Number
For each frame, the system:
- Extracts the defined scan area
- Applies multiple preprocessing techniques (grayscale, binary threshold, morphological operations)
- Attempts barcode detection with each method
- Parses successful reads into human-readable format
- Returns both prettified data and raw barcode content
- Python 3.7+
- Webcam or camera device (iPhone or high-quality cameras recommended for dense PDF417 barcodes)
- Modern web browser with camera permissions
-
Clone/Download the project files
-
Install Dependencies:
pip install -r requirements.txtsudo apt-get install libzbar0 libzbar-devImportant: This scanner tracks successful scans for statistical purposes only. Each successful scan increments a counter that can be accessed via the /scan-stats API endpoint. No personal data from licenses is stored - only scan counts and timestamps are recorded.
Example: GET https://dl-scanner.chrisccluk.live/scan-stats
python app.py # Default port 5000
python app.py 8080 # Custom port 8080The server starts at http://localhost:5000 (or your specified port)
- Select Camera: Choose from available cameras in the dropdown
- Start Camera: Click "Start Camera" to begin video feed
- Customize Overlay: Adjust box width/height percentages or use URL parameters (
?width=80&height=20) - Position License: Place driver's license so the back barcode is within the green alignment box
- Automatic Scanning: The app continuously scans every second
- Results: When successful, displays:
- Annotated image showing detected barcode area
- Prettified license information (copy-pasteable)
- Collapsible raw barcode data with copy button
- Download option for annotated image
- Camera Quality: Use iPhone or high-quality cameras - PDF417 barcodes contain dense information requiring good resolution
- Lighting: Ensure even, bright lighting without shadows or glare
- Positioning: Keep the PDF417 barcode fully within the green box
- Orientation: Use the flip camera button if the barcode appears mirrored
- Stability: Hold the license steady during scanning
- Distance: Maintain appropriate distance for clear barcode visibility
- Angle: Keep the license flat and parallel to the camera
- Real-time Detection: Continuous scanning without manual capture
- Multiple Decoders: Fallback detection methods for reliability
- Camera Controls: Flip camera orientation for better positioning
- Scan Statistics: Persistent counter tracking successful scans
- Data Export: Copy prettified or raw data to clipboard
- Image Download: Save annotated scan results
- Responsive Design: Works on desktop and mobile browsers
- Security: No server-side file storage, base64 image embedding
- Privacy: Only scan statistics stored, no personal data retention
- Session Management: Automatic idle user redirection to prevent resource consumption
No Detection:
- Improve lighting conditions
- Ensure barcode is within green alignment box
- Try different camera angles
- Check if ZXing-CPP is installed for better detection
Camera Issues:
- Grant camera permissions in browser
- Try different cameras from the dropdown
- Refresh page and restart camera
Poor Image Quality:
- Clean camera lens
- Increase lighting
- Reduce camera shake
- Move closer/farther for optimal focus
- Backend: Flask web server with persistent scan statistics
- Computer Vision: OpenCV for image processing
- Barcode Libraries: ZXing-CPP, pyzbar, OpenCV barcode detector
- Frontend: Vanilla JavaScript with WebRTC camera access
- Data Storage: JSON file for scan counter persistence
- Security: Client-side image handling, no server file storage

