A comprehensive Python-based application that connects to IP cameras via RTSP protocol, detects and decodes QR codes in real-time, and saves the decoded information to files. Built with Object-Oriented Programming principles and designed for reliability and scalability.
- Domain-Specific Processing: Automatically detects QR codes from
elites.liupe.xyzdomain - Base64 Code Extraction: Extracts base64 codes from URLs like
https://elites.liupe.xyz/qr?code=MDY1NA== - Separate Storage: Saves extracted base64 codes to dedicated JSON file for easy access
- Duplicate Prevention: Prevents saving duplicate base64 codes within timeout period
- RTSP Protocol Support: Connect to multiple IP cameras using RTSP URLs
- Real-time QR Detection: Advanced QR code detection using pyzbar with image preprocessing
- Multi-Camera Support: Handle up to 4+ simultaneous camera streams
- Duplicate Prevention: Configurable timeout to prevent duplicate QR code logging
- Multiple Output Formats: Save data in JSON, CSV, or plain text formats
- File Rotation: Automatic file rotation based on size and time limits
- Threaded Processing: Concurrent processing for optimal performance
- Automatic Reconnection: Robust reconnection logic with exponential backoff
- Secure Configuration: Encrypted storage of camera credentials
- Modern Web Interface: User-friendly responsive web dashboard with Bootstrap 5
- CLI/Headless Mode: Command-line operation for server deployments
- Comprehensive Logging: Detailed logging with file rotation
- Statistics Monitoring: Real-time performance and detection statistics
- Minimum RAM: 4GB (8GB recommended)
- CPU: Multi-core processor (4+ cores recommended)
- Network: Stable network connection for RTSP streams
- Storage: 500MB for application + space for data files
- Python: 3.8 or higher
- Operating System: Windows, Linux, macOS
- Network Cameras: IP cameras with RTSP support
git clone https://github.com/sithulaka/ip_camera_qr_scanner.git
cd ip_camera_qr_scannerpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtsudo apt-get update
sudo apt-get install python3-opencv libzbar0sudo yum install opencv-python zbarDependencies are typically installed automatically with pip.
pip install -e .Edit the configuration file at config/default_config.ini:
[cameras]
camera_01 = rtsp://admin:password@192.168.1.100:554/stream
camera_02 = rtsp://admin:password@192.168.1.101:554/stream
[storage]
output_format = json
output_directory = ./qr_data
file_rotation_size_mb = 100
[processing]
fps_limit = 30
duplicate_timeout_seconds = 5
max_threads = 4Supported RTSP URL formats:
rtsp://username:password@ip_address:port/streamrtsp://ip_address:port/streamrtsp://username:password@hostname/path/to/stream
- Camera credentials are automatically encrypted
- Configuration files use secure permission settings
- No credentials are logged in plain text
# Run with modern web interface (either entry point works)
python3 main.py
# OR
python3 qr_scanner.py
# Opens web dashboard at: http://localhost:8000# Run without web interface (for servers)
python3 main.py --cli
# OR
python3 qr_scanner.py --clipython3 main.py --help
Options:
--cli Run in CLI/headless mode (no web interface)
--config FILE Use custom configuration file
--test-cameras Test camera connections and exit
--version Show version information# Test all configured cameras
python3 main.py --test-cameras
# OR
python3 qr_scanner.py --test-cameras
# Test with custom config
python3 main.py --test-cameras --config my_config.iniWhen QR codes from elites.liupe.xyz domain are detected, the system automatically extracts the base64 code and saves it to a separate file:
qr_data/elites_base64_codes.json
[
{
"timestamp": "2025-08-05T16:29:15.872790",
"base64_code": "MDY1NA==",
"original_url": "https://elites.liupe.xyz/qr?code=MDY1NA==",
"camera_id": "camera_01",
"camera_ip": "192.168.1.100",
"confidence": 1.0,
"frame_number": 0
}
]{
"timestamp": "2025-01-20T10:30:45.123Z",
"camera_id": "camera_01",
"camera_ip": "192.168.1.100",
"qr_data": "https://example.com/data",
"qr_type": "URL",
"confidence": 0.95,
"processing_time_ms": 25,
"frame_number": 12345
}timestamp,camera_id,camera_ip,qr_data,qr_type,confidence,processing_time_ms,frame_number
2025-01-20T10:30:45.123Z,camera_01,192.168.1.100,https://example.com,URL,0.95,25,12345[2025-01-20 10:30:45] Camera: camera_01 | Type: URL | Data: https://example.com | Confidence: 0.95
The system automatically detects and categorizes QR codes:
- URL: Web links (http://, https://, www.)
- EMAIL: Email addresses
- PHONE: Phone numbers
- WIFI: WiFi configuration
- SMS: SMS/text messages
- CONTACT: vCard contact information
- LOCATION: Geographic coordinates
- NUMERIC: Pure numbers
- TEXT: Plain text content
- Camera Grid: Live camera status with multiple view modes (2x2, 3x3, list)
- Control Panel: Start/stop system, test cameras, access settings
- Statistics Cards: Real-time metrics (cameras, QR codes, FPS, storage)
- QR Detection Log: Live feed of detected QR codes with type indicators
- System Logs: Real-time color-coded system messages
- Cameras Tab: Add/remove/configure cameras with RTSP URLs
- Processing Tab: FPS limits, threads, confidence thresholds
- Storage Tab: Output formats, file rotation, backup options
- Real-time Updates: All changes applied instantly
- FPS Limit: 15-30 FPS per camera
- Max Threads: Number of CPU cores
- Buffer Size: 10-20 frames
- Confidence Threshold: 0.8 for high accuracy
# Check system resources
htop
# Monitor network usage
iftop
# Check disk space
df -h# Test individual camera
ffmpeg -i "rtsp://camera-url" -t 10 -f null -
# Check network connectivity
ping camera-ip-address
# Verify RTSP port
telnet camera-ip-address 554- Ensure good lighting conditions
- Check camera focus and positioning
- Adjust confidence threshold in configuration
- Verify QR code is not damaged or distorted
- Reduce FPS limit for multiple cameras
- Increase processing threads if CPU allows
- Enable hardware acceleration if available
- Check network bandwidth usage
Application logs are stored in:
logs/qr_scanner_YYYYMMDD.log- Log rotation occurs daily with 5-day retention
# Enable verbose logging
python src/main.py --debugip_camera_qr_scanner/
├── src/
│ ├── camera/ # Camera management
│ ├── processing/ # QR code detection
│ ├── storage/ # Data persistence
│ ├── ui/ # GUI components
│ ├── config/ # Configuration management
│ └── utils/ # Utilities and logging
├── tests/ # Unit and integration tests
├── config/ # Configuration files
└── docs/ # Documentation
# Install test dependencies
pip install -e .[dev]
# Run all tests
pytest
# Run with coverage
pytest --cov=src tests/
# Run specific test
pytest tests/test_qr_decoder.py# Format code
black src/
# Lint code
flake8 src/
# Type checking
mypy src/from src.camera.camera_manager import CameraManager
manager = CameraManager(camera_settings)
manager.start_all_cameras()
manager.add_frame_callback(callback_function)from src.processing.qr_decoder import QRDecoder
decoder = QRDecoder(confidence_threshold=0.8)
qr_codes = decoder.decode_frame(frame, camera_id, camera_ip)from src.storage.storage_manager import StorageManager
storage = StorageManager(storage_settings)
storage.store_qr_data(qr_data)- Fork the repository
- Create a feature branch
- Make changes with tests
- Run quality checks
- Submit pull request
- Follow PEP 8 style guidelines
- Write comprehensive tests
- Update documentation
- Use type hints
- Add logging for debugging
Sithulaka
- GitHub: github.com/sithulaka
This project is licensed under the MIT License - see the LICENSE file for details.
- Check the troubleshooting section
- Review log files for errors
- Test camera connections independently
- Verify configuration settings
When reporting issues, please include:
- Operating system and version
- Python version
- Camera model and RTSP URL format
- Error messages and log excerpts
- Steps to reproduce the problem
- Initial release
- Multi-camera RTSP support
- Real-time QR code detection
- GUI and headless modes
- Comprehensive configuration system
- File rotation and backup support
- Performance monitoring and statistics
IP Camera QR Code Scanner - Built with Python for reliability and performance by Sithulaka.