An advanced, high-accuracy image processing system that uses computer vision and OCR (Optical Character Recognition) to automatically detect and recognize vehicle license plates from images with improved accuracy and robustness.
- Latest Improvements
- Screenshots
- Quick Demo
- Features
- System Architecture
- Installation
- Usage
- Technical Details
- Applications
- Performance Optimization
- Troubleshooting
- Future Enhancements
- Dependencies
- License
- Multi-method Detection: Combines Haar cascades, edge detection, and MSER for better plate localization
- Advanced Preprocessing: 6 different image enhancement techniques including CLAHE and denoising
- Smart OCR: 8 different Tesseract configurations with optimal parameters
- Multiple Attempts: Tries enhanced image, original image, and different regions automatically
- Confidence Scoring: Advanced scoring system considering method, preprocessing, and text patterns
- Optimal Sizing: Automatically resizes images to optimal OCR dimensions (32-48px height)
- Pattern Validation: Enhanced validation for various international license plate formats
- OCR Error Correction: Smart correction of common OCR errors (O/0, I/1, S/5, etc.)
- Context-aware Processing: Adapts correction based on expected character distribution
- Graceful Degradation: Falls back to alternative methods when primary detection fails
- Regional Processing: Tries center and bottom regions when full detection fails
- Error Handling: Comprehensive error handling with detailed logging
- Performance Optimization: Intelligent processing with time/accuracy balance
User-friendly web interface for uploading vehicle images
License plate detection with confidence scoring and detailed processing information
Example of successful license plate recognition on various vehicle types
- Upload: Select an image containing a vehicle with a visible license plate
- Process: The system automatically detects and extracts the license plate text
- Results: View the recognized license plate number with confidence level and processing details
The system works with various vehicle types and license plate formats, providing reliable recognition even in challenging conditions.
- Intelligent Plate Detection: Uses multiple detection methods with confidence scoring
- Advanced Image Preprocessing: 6 different enhancement techniques for optimal OCR
- Robust OCR: Multiple OCR configurations for maximum text extraction accuracy
- Smart Pattern Validation: Validates against common license plate formats worldwide
- Confidence Scoring: Provides detailed confidence levels (high, medium, low)
- Multi-attempt Processing: Tries multiple approaches automatically for best results
- Web Interface: User-friendly web interface with detailed processing feedback
- Real-time Processing: Fast processing with intelligent method selection
The system consists of several key components:
- Image Preprocessing Module: Enhances image quality for better OCR results
- License Plate Detection: Locates license plate regions in vehicle images
- OCR Engine: Extracts text from detected license plates using Tesseract
- Text Validation: Validates and cleans extracted text using pattern matching
- Web Interface: Flask-based web application for user interaction
- Python 3.7+ installed on your system
- Tesseract OCR installed:
- Windows: Download from GitHub releases
- Linux:
sudo apt-get install tesseract-ocr - macOS:
brew install tesseract
-
Clone or download the project:
git clone https://github.com/shakiliitju/Car-Number-Plate-Recognition-System.git cd Car-Number-Plate-Recognition-System -
Create a virtual environment (recommended):
python -m venv venv # Windows venv\Scripts\activate # Linux/macOS source venv/bin/activate
-
Install Python dependencies:
pip install -r requirements.txt
-
Verify Tesseract installation:
tesseract --version
Note: If you encounter "tesseract not found" error on Windows, you may need to add Tesseract to your system PATH or update the
app.pyfile with the correct Tesseract executable path.
-
Start the Flask server:
python app.py
-
Open your web browser and navigate to:
http://localhost:5000 -
Upload an image containing a vehicle with visible license plate
-
View results including:
- Detected license plate number
- Confidence level
- Processing steps information
- PNG, JPG, JPEG, GIF, BMP, TIFF
- Maximum file size: 16MB
- Recommended: Clear images with visible license plates
The project includes a comprehensive set of test images in the test images/ folder with various vehicle types and license plate formats. These images can be used to test the system's accuracy and performance across different scenarios.
- Image Resizing: Large images are resized for optimal processing speed
- Grayscale Conversion: Converts color images to grayscale
- Noise Reduction: Applies Gaussian blur to reduce image noise
- Adaptive Thresholding: Creates binary images for better text detection
- Morphological Operations: Cleans up the binary image
- Haar Cascade Classification: Uses pre-trained cascades when available
- Edge Detection: Canny edge detection followed by contour analysis
- Aspect Ratio Filtering: Filters contours based on typical license plate dimensions
- Uses Tesseract OCR with multiple PSM (Page Segmentation Mode) configurations
- Character whitelist for alphanumeric characters only
- Multiple attempts with different configurations for better accuracy
Supports various license plate formats:
- XX00XX0000 (2 letters, 2 numbers, 2 letters, 4 numbers)
- XXX000 (3 letters, 3 numbers)
- XXX0000 (3 letters, 4 numbers)
- 000XXX (3 numbers, 3 letters)
- And many more regional variations
This ACNPR system can be used in various scenarios:
- Traffic Management: Monitor and track vehicles in traffic systems
- Toll Collection: Automated toll collection based on license plate recognition
- Parking Automation: Automatic entry/exit control in parking facilities
- Law Enforcement: Vehicle tracking and monitoring for security purposes
- Access Control: Restricted area access based on vehicle identification
- Fleet Management: Track company vehicles and logistics
- Image Resizing: Automatically resizes large images for faster processing
- Multi-method Detection: Uses multiple detection algorithms for better accuracy
- Efficient OCR: Optimized OCR configurations for license plate text
- Error Handling: Robust error handling for various image types and qualities
-
Tesseract not found error:
- Ensure Tesseract OCR is properly installed
- Add Tesseract to your system PATH
-
Poor recognition accuracy:
- Use high-quality, well-lit images
- Ensure license plate is clearly visible and not obscured
- Try images with minimal skew or rotation
-
No license plate detected:
- Check if the license plate is clearly visible in the image
- Try images with better contrast between plate and background
- Ensure the license plate takes up a reasonable portion of the image
- Use images with good lighting conditions
- Ensure license plates are not tilted or skewed
- Clean license plates work better than dirty or damaged ones
- Higher resolution images generally provide better results
When you upload an image the application saves a small set of debugging artifacts to help diagnose detection and OCR issues. This makes it much easier to inspect what the pipeline actually saw when Tesseract produced a wrong result.
- Location:
uploads/(a new session folder is created for each upload) - Folder naming:
Car Number-1,Car Number-2, ... (sequential). If folder creation fails the app falls back to a UUID-named folder.
Files saved per session (summary):
- The original uploaded image (same filename you uploaded)
plate.pngβ cropped plate region detected by the pipeline (if any)- Detection images:
sobel_combined.pngβ combined Sobel edge map used for detectioncandidates_annotated.pngβ annotated image showing all detection candidates and scorescandidate_best_<score>.pngβ cropped image of the top-scoring candidate
- Preprocessing images (one file each):
bilateral.pnginverted.pngsimple_otsu.pngmorphological.png
Notes:
- The system intentionally does NOT save OCR text output files (no
.txtfiles are stored) to reduce persisted sensitive text. - If a particular preprocessing method didn't produce a usable image it will be omitted from the session folder.
How to change or disable saving
- To change the uploads root folder, edit
app.config['UPLOAD_FOLDER']inapp.py. - To stop saving debug artifacts, remove or comment out the lines in
app.pythat setrecognizer.debug_dir = session_dirand the image-write sections inside the recognizer methods. The code is centralized so this is quick to toggle. - If you prefer UUID folders instead of sequential
Car Number-Nfolders, change the upload handler to useuuid.uuid4().hexfor folder names (the code already falls back to this on error).
Privacy and cleanup
- The
uploads/folder can grow over time. Periodically remove oldCar Number-*folders or add a small cleanup script to keep recent N sessions. - Avoid storing images from production with sensitive personal data for longer than necessary; implement a retention policy if deploying this system in production.
- Support for multiple license plates in a single image
- Real-time video processing capabilities
- Integration with databases for vehicle tracking
- Support for more international license plate formats
- Machine learning models for improved detection accuracy
- Flask: Web framework for the user interface
- OpenCV (cv2): Computer vision library for image processing
- Pytesseract: Python wrapper for Tesseract OCR engine
- NumPy: Numerical computing library for array operations
- Pillow (PIL): Python Imaging Library for image handling
- Tesseract OCR: External OCR engine (must be installed separately)
Car-Number-Plate-Recognition-System/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ README.md # Project documentation
βββ LICENSE # License file
βββ static/ # CSS and JavaScript files
β βββ style.css
β βββ script.js
βββ templates/ # HTML templates
β βββ index.html
βββ screenshots/ # Demo screenshots
β βββ 1.png
β βββ 2.png
β βββ 3.png
βββ test images/ # Sample test images
β βββ [Various car images]
βββ uploads/ # Temporary upload directory
This project is for educational and research purposes. Please ensure compliance with local laws and regulations when using for commercial applications involving vehicle monitoring or data collection.