Skip to content

Conversation

@iamdevdhanush
Copy link
Contributor

What is this Python project?

This is a real-time Number Plate Detection project using Python and OpenCV.
It detects vehicle number plates from webcam feed, images, or video, and optionally saves cropped plate images.
It is beginner-friendly and modular, so others can expand it for automation, security, or traffic monitoring projects.

Features

  • Real-time detection using OpenCV (Haar cascades + contour filtering)
  • Works with images, video, and webcam feed
  • Saves detected number plates as images with timestamp
  • Modular and easy to extend for ANPR or traffic analytics projects

Why it is useful / Difference from similar projects

  • Lightweight and runs in real-time without heavy models
  • Easy-to-understand code for beginners learning OpenCV and image processing
  • Can be integrated with OCR tools like EasyOCR for full license plate recognition
  • Serves as a base for traffic monitoring, security, or AI experiments

Anyone who agrees with this pull request could submit an Approve review to it.

@github-actions
Copy link

👋 @iamdevdhanush
Thank you for raising your pull request.
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.

Copy link
Contributor

@iamwatchdogs iamwatchdogs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iamdevdhanush, Please make the following changes:

  • Remove mp4 file
  • Remove xml file
  • Update your program (either with suggested workaround or your own logic that doesn't include those file locally)
  • Remove the licensing part from README.md

Important

To remove those mp4 and xml file, please perform interactive rebasing along with force push to the branch which you made this PR. This would remove the existance of those files from commit history.

Note

If you need help with interactive rebasing, please refer to YouTube tutorials or ping @iamwatchdogs for help. Remember, Closing PR won't fix this issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this mp4 file from this PR. The PR shouldn't include any binary files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this xml file from this PR. Despite being a formatted text file, this is more like a config file that contains some sort of metadata.

Comment on lines 1 to 16
import cv2
import os
import time

cascade_path = 'indian_license_plate.xml'
plate_cascade = cv2.CascadeClassifier(cascade_path)
if plate_cascade.empty():
print(f"Error loading cascade from {cascade_path}")
exit()

os.makedirs('plates', exist_ok=True)
video_path = 'Trafic Camera.mp4'
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
print(f"Error opening video file {video_path}")
exit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have requested that you remove the required files (mp4 file and xml file) for this program to work properly. Here's a workaround that could work for your program:

Suggested change
import cv2
import os
import time
cascade_path = 'indian_license_plate.xml'
plate_cascade = cv2.CascadeClassifier(cascade_path)
if plate_cascade.empty():
print(f"Error loading cascade from {cascade_path}")
exit()
os.makedirs('plates', exist_ok=True)
video_path = 'Trafic Camera.mp4'
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
print(f"Error opening video file {video_path}")
exit()
import cv2
import os
import time
import urllib.request
import tempfile
def download_if_url(path):
if isinstance(path, str) and path.startswith(('http://', 'https://')):
try:
suffix = os.path.splitext(path)[1] or ''
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
tmp.close()
print(f"Downloading {path} ...")
urllib.request.urlretrieve(path, tmp.name)
return tmp.name
except Exception as e:
print(f"Failed to download {path}: {e}")
return path
return path
cascade_path = 'https://raw.githubusercontent.com/iamdevdhanush/Number-Plate-Detection/refs/heads/main/indian_license_plate.xml'
cascade_path = download_if_url(cascade_path)
plate_cascade = cv2.CascadeClassifier(cascade_path)
if plate_cascade.empty():
print(f"Error loading cascade from {cascade_path}")
exit()
os.makedirs('plates', exist_ok=True)
video_path = 'https://github.com/iamdevdhanush/Number-Plate-Detection/raw/refs/heads/main/Trafic%20Camera.mp4'
video_path = download_if_url(video_path)
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
print(f"Error opening video file {video_path}")
exit()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iamwatchdogs,

I’ve updated the implementation to remove any dependency on local mp4 or xml files by using OpenCV’s built-in Haar cascade and defaulting to webcam input.

I’ve also performed an interactive rebase and force-pushed the branch so the mp4 and xml files are completely removed from the commit history, and removed the license section from the README.

Please let me know if any further changes are required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iamdevdhanush,

We have reviewed your changes. We want to remind you that reverting changes doesn't completely remove the traces of"input" files (such as mp4 or xml). These files can be recovered by reverting the "deleted" revert commits.

We want you to perform interactive rebasing for this branch to edit the initial commit (i.e., 6f94836c) and delete the mp4 & xml file, and during the same interactive rebasing session, remove the reverting commit that you have made. After all these changes, force-push your reorganised commit history to the remote branch.

We can proceed with these changes. Please feel free to ask any questions for clarification or help needed.

Tip

Here's a sample YouTube Tutorial for using interactive rebasing.

@iamdevdhanush iamdevdhanush closed this by deleting the head repository Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants