A comprehensive standalone ANPR (Automatic Number Plate Recognition) system with Streamlit web interface, featuring Norwegian vehicle registry integration and support for Hailo AI accelerators.
- π― Complete ANPR Pipeline: Video capture β Inference β License plate reading β Registry validation
- π Web Interface: Interactive Streamlit UI with real-time processing
- π€ AI-Powered OCR: PaddleOCR HTTP API for accurate license plate text extraction
- π³π΄ Norwegian Registry: Dual lookup against Norwegian vehicle registries
- πΎ Database Integration: SQLite database for tracking all registry checks
- π¬ Video Processing: Support for camera recording and batch video processing
- β‘ Hardware Acceleration: Optional Hailo AI accelerator support
- π Fallback Support: Works with or without specialized hardware
- π Internationalization: English and Norwegian interface
- π Secure Configuration: Environment-based API key management
# Install the package
pip install anpr-standalone
# Or install from source
git clone https://github.com/OsloVision/anpr-standalone.git
cd anpr-standalone
pip install -e .# Clone the repository
git clone https://github.com/OsloVision/anpr-standalone.git
cd anpr-standalone
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\\Scripts\\activate
# Install dependencies
pip install -r requirements.txtFor video recording functionality:
# Ubuntu/Debian
sudo apt-get install v4l-utils ffmpeg
# macOS
brew install ffmpeg
# Windows
# Download ffmpeg from https://ffmpeg.org/download.htmlCopy the environment template and configure your API keys:
cp .env.example .env
nano .envAdd your API configuration to .env:
# Required: PaddleOCR API URL for license plate text extraction
PADDLEOCR_API_URL=http://localhost:5000
# Optional: Norwegian Vehicle Registry API key
VEHICLE_API_KEY=your-norwegian-vehicle-api-key-hereThe system supports multiple inference backends:
- Hailo AI Accelerator (if available)
- Demo Mode (for testing without hardware)
- ONNX Runtime (coming soon)
- TensorFlow (coming soon)
# Using installed package
anpr-ui
# Or run directly
streamlit run streamlit_ui.py- π¬ Capture: Record videos using connected USB camera
- π§ Infer: Process videos to detect and extract license plates
- π¨ Postprocess: Run ANPR analysis with Norwegian registry lookup
# Process a single image
python -m anpr.license_plate_reader image.jpg
# Process with registry check
python -m anpr.license_plate_reader --check-registry image.jpg
# Batch process directory
python -m anpr.license_plate_reader --batch /path/to/images/The Streamlit web interface provides a complete 3-step workflow:
- Connect USB camera
- Configure recording settings
- Record traffic videos
- View recent captures
- Load AI model (Hailo HEF or other formats)
- Process captured videos
- Extract license plate regions
- Generate detection crops
- Configure API keys
- Run ANPR on detection crops
- Check Norwegian vehicle registries
- Save results to database
- Move processed crops to organized folders
import anpr
# Initialize ANPR system
anpr_system = anpr.ANPRSystem()
# Process an image
result = anpr_system.process_image("license_plate.jpg")
print(f"License plate: {result.license_plate}")
print(f"Registry status: {result.registry_status}")
# Process a video
results = anpr_system.process_video("traffic_video.mp4")
for result in results:
print(f"Frame {result.frame_number}: {result.license_plate}")from anpr import LoanStatusDB
# Initialize database
db = LoanStatusDB("anpr_results.db")
# Query results
records = db.list_all_records()
for record in records:
print(f"{record.numberplate}: {record.loan_status}")
# Check specific plate
result = db.get_loan_status("ABC123")
if result:
print(f"Found: {result.loan_status}")βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Video Input βββββΆβ AI Inference βββββΆβ ANPR Engine β
β (Camera/File) β β (Hailo/Demo/etc)β β(PaddleOCR API) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Database ββββββ Registry ββββββ Text Extract β
β (SQLite) β β Lookup (NO) β β & Validate β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
anpr-standalone/
βββ anpr/ # Core ANPR functionality
β βββ license_plate_reader.py
β βββ loan_db_utils.py
β βββ norwegian_vehicle_api.py
βββ hailo/ # Hailo AI integration
β βββ hailo_inference.py
β βββ toolbox.py
βββ inference/ # Generic inference pipeline
β βββ postprocessing.py
βββ utils/ # Utility functions
β βββ inference_engine.py
β βββ video_utils.py
βββ streamlit_ui.py # Web interface
Run the test suite:
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run with coverage
pytest --cov=anpr tests/
# Run specific test
pytest tests/test_anpr.py::test_license_plate_reading- Hailo-8: ~30-50 FPS (640x640 input)
- Demo Mode: ~100+ FPS (mock inference)
- Memory Usage: ~200-500MB depending on model
- License Plate Detection: 85-95% (depends on video quality)
- Text Recognition: 90-98% (PaddleOCR PP-OCRv5)
- Registry Matching: 95%+ (official Norwegian APIs)
| Variable | Required | Description |
|---|---|---|
PADDLEOCR_API_URL |
Yes | PaddleOCR API endpoint URL (default: http://localhost:5000) |
VEHICLE_API_KEY |
No | Norwegian vehicle registry API key |
VEHICLE_API_BASE_URL |
No | Custom registry API endpoint |
LOG_LEVEL |
No | Logging level (INFO, DEBUG, WARNING) |
Edit config.json to customize inference parameters:
{
"fast": {
"score_threshold": 0.5,
"nms_threshold": 0.4
},
"v5": {
"score_threshold": 0.5,
"nms_threshold": 0.4
}
}We welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Clone and setup development environment
git clone https://github.com/OsloVision/anpr-standalone.git
cd anpr-standalone
python -m venv venv
source venv/bin/activate
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run code formatting
black .
flake8 .This project is licensed under the MIT License - see the LICENSE file for details.
- Hailo for AI accelerator support
- OpenAI for GPT-4o-mini vision capabilities
- Norwegian Public Roads Administration for vehicle registry APIs
- Streamlit for the excellent web framework
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@oslovision.com
- v1.1: ONNX Runtime support
- v1.2: TensorFlow Lite backend
- v1.3: REST API server mode
- v1.4: Docker containers
- v1.5: Cloud deployment guides
- v2.0: Multi-country registry support
Built with β€οΈ by OsloVision
