This project detects and reads vehicle number plates from images using OpenCV and Tesseract OCR.
- Loads an image and resizes it for processing
- Converts the image to grayscale and applies filtering
- Detects edges and contours to locate the number plate
- Extracts the number plate region and applies thresholding
- Uses Tesseract OCR to read the number plate text
- Saves intermediate and final results as images
- Python 3.10+
- OpenCV (
cv2) - pytesseract
- matplotlib
- Tesseract OCR (installed on your system)
-
Clone this repository:
git clone https://github.com/yourusername/number-plate-detector.git cd number-plate-detector -
Install Python dependencies:
pip install opencv-python pytesseract matplotlib
-
Install Tesseract OCR:
- Ubuntu:
sudo apt-get install tesseract-ocr - Windows:
Download from Tesseract at UB Mannheim
- Ubuntu:
-
Place your input image as
fi.jpegin the project directory.
Run the script:
python app.py- The script will process
fi.jpegand save output images at each step. - The detected number plate and OCR result will be saved as images.
output_6_1_original.jpg: Resized original imageoutput_6_2_gray.jpg: Grayscale imageoutput_6_2_filtered.jpg: Filtered imageoutput_6_3_edges.jpg: Edge-detected imageoutput_6_3_contours.jpg: Image with contours drawnoutput_6_4_plate.jpg: Cropped number plate regionoutput_6_5_thresh.jpg: Thresholded plate imageoutput_6_6_ocr_result.jpg: Plate image with OCR result
- Make sure the path to Tesseract in
app.pymatches your system installation. - For best results, use clear images of number plates.
MIT License
Created with OpenCV and Tesseract