This project is a web application built using Flask, EasyOCR, and YOLO for license plate detection and optical character recognition (OCR). The application allows users to upload images, detects license plates in the images, and extracts the text from the detected plates.
- License Plate Detection: Utilizes the YOLO model to detect license plates in the uploaded images.
- Optical Character Recognition (OCR): Uses EasyOCR to read text from the detected license plates.
- Image Processing: Processes the image to enhance character recognition.
- Web Interface: Provides an intuitive web interface for uploading images and displaying results.
- Python 3.6+
- Flask
- EasyOCR
- Ultralytics YOLO
- OpenCV
-
Clone the Repository:
git clone https://github.com/your-repo/license-plate-ocr.git cd license-plate-ocr -
Create a Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install Dependencies:
pip install -r requirements.txt
-
Download YOLO Model:
Place the
best.ptYOLO model file in the project directory.
-
Run the Application:
python app.py
-
Open in Browser:
Navigate to
http://127.0.0.1:5000/in your web browser. -
Upload Image:
- On the homepage, upload an image containing a license plate.
- The application will process the image, detect the license plate, and display the OCR results.
app.py: Main application file.templates/: HTML templates for the web interface.index.html: Homepage template with file upload form.result.html: Template to display OCR results and processed images.
static/: Static files (CSS, JS, images).requirements.txt: List of Python dependencies.
The Flask app is the core of the web application, handling requests and rendering templates.
- Routes:
/: Handles GET and POST requests for the homepage and file uploads.
The process_image function processes the uploaded image:
- License Plate Detection: Uses the YOLO model to detect license plates.
- Image Cropping and Scaling: Crops the detected license plate region and scales it for better OCR.
- Grayscale Conversion and Thresholding: Enhances the image for better text recognition.
- OCR: Uses EasyOCR to read text from the processed image.
The results, including the original image, cropped license plate image, and OCR result, are converted to base64 and rendered in the result.html template.
- Multi-language Support: Extend OCR capabilities to support more languages.
- Real-time Detection: Implement real-time video stream processing.
- Improved UI: Enhance the user interface for better user experience.
This project is based on research conducted on Egyptian car plate recognition systems. You can read the full paper here.