Number Plate Detection
Hey Curious,
here comes the Third “ mini “ project.
This is a Mini project which deals with NLP and Deep Learning and helps to detect the Car Number on Number plate using opencv and imutils
> Imutils are a series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and both Python 2.7 and Python 3.
Setup instructions :
In order to run this script, You just need the following modules:
- Opencv :
pip install opencv-python2. Imutils :
pip install imutilsInputing the image path
input = 'photo_of_car.png'image = cv2.imread(input)cv2.imshow("Input Image", image)new_width = 500
Resizing the image
image = im.resize(image, width=new_width)Converting bgr to gray scaling
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)Lets find the boundries of the image or say contours
cnts,hir = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)cnts=sorted(cnts, key = cv2.contourArea, reverse = True)[:10]NumberPlateCnt = Noneprint(“Number of Contours found : “ + str(len(cnts)))
here comes the function of the project :
count = 0for c in cnts: peri = cv2.arcLength(c, True) epsilon = 0.01 * peri approx = cv2.approxPolyDP(c, epsilon, True) if len(approx) == 4: print(approx) NumberPlateCnt = approx break
Applying detection to the Function :
cv2.imshow(“Gray scale Image”, gray)cv2.imshow(“After Applying Bilateral Filter”, filtered_image)cv2.imshow(“After Canny Edges”, edged)cv2.drawContours(image, [NumberPlateCnt], -1, (255,0,0), 2)cv2.imshow(“Output”, image) #getting output imagecv2.waitKey(0)
How to Run the Project :
For .py files:
Get Virinchi-Thinks’s stories in your inbox
Join Medium for free to get updates from this writer.
open .py file and install all dependencies
open command prompt by typing cmd at adress bar of folder
type python file_name.py
check for error most of the error will be either for missing libraries or some may be of having no image in such case download similar context image.
for videocapture(0) error : it will only raise if you have another webcam and primary webcam is not working in such case place videocapture(1) and it’ll be running just fine
Output:
To Get more Insightful Content do follow my Instagram Page : click to redirect →
GitHub Code : click to redirect →








