End-to-end number plate text extraction for Indian vehicles using OpenCV and Tesseract OCR.
- Preprocesses the image (blur, grayscale, Sobel, morphology)
- Detects candidate plate regions via contours and geometric filtering
- Cleans plate ROI and applies Tesseract OCR
- Prints the extracted alphanumeric number plate text
Example output:
Extracted Number Plate Text: KA05MN1234
- Python 3.9+ (works on Windows, macOS, Linux)
- System Tesseract OCR:
- Windows: install from https://github.com/tesseract-ocr/tesseract or https://tesseract-ocr.github.io/tessdoc/Installation.html
- Remember the full path to
tesseract.exe
(e.g.C:\Program Files\Tesseract-OCR\tesseract.exe
)
Python packages are listed in requirements.txt
:
- numpy
- opencv-python
- pillow
- pytesseract
- matplotlib (only if you use
--visualize
)
- Create and activate a virtual environment
py -m venv .venv
.venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Install Tesseract OCR (if not already installed)
- Download and install for Windows.
- If
tesseract.exe
is not on your PATH, pass its location with--tesseract-cmd
.
- Run on a sample image
python Program.py --image Dataset\7.jpeg --tesseract-cmd "C:\\Program Files\\Tesseract-OCR\\tesseract.exe"
Optional: see intermediate processing steps
python Program.py --image Dataset\7.jpeg --visualize --tesseract-cmd "C:\\Program Files\\Tesseract-OCR\\tesseract.exe"
Notes
frontend.html
is a static demo page; it doesn’t run OCR in the browser. UseProgram.py
for detection.
Program.py
– CLI script to run ANPR on an imageDataset/
– sample imagesSearch_Image/Car.jpeg
– demo image used by the static frontendfrontend.html
– static landing page (no backend)requirements.txt
– Python dependencies
- Tesseract not found: Install it and/or provide
--tesseract-cmd
. - Empty result: try a higher quality image or run with
--visualize
to inspect steps. - OpenCV errors on reading image: verify path and file extension.
PRs are welcome. Please include a brief description and sample image if relevant.
See LICENSE
file.
Replace square-bracket placeholders with your own if needed.
- Initialize the repository (run in the project folder)
git init
git add .
git commit -m "Initial commit: ANPR CLI, README, requirements"
- Create the GitHub repo
- Go to https://github.com/new and create a repository named:
Automated Number Plate Detection
- Or via CLI (requires
gh
):
gh repo create "MNSamarth/Automated Number Plate Detection" --public --source . --remote origin --push
- If you created the repo in the browser, set the remote and push
git remote add origin https://github.com/MNSamarth/Automated-Number-Plate-Detection.git
git branch -M main
git push -u origin main
If your repository slug contains spaces, GitHub will normalize it with dashes. Verify the exact URL after creation and update the git remote add origin
URL accordingly.
- Verify on GitHub
- Open the repo page and confirm files are present and README renders.