Skip to content

Commit 7e69458

Browse files
committed
Automatic number plate recognition Project Added
1 parent f875632 commit 7e69458

29 files changed

+90
-0
lines changed

Data Science Project/APNR/.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Data Science Project/APNR/.idea/APNR.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Data Science Project/APNR/.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Data Science Project/APNR/.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Data Science Project/APNR/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Data Science Project/APNR/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

Data Science Project/APNR/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# APNR
2+
Automatic number-plate recognition(Python Project)
3+
->A basic Python and Data Science project as a part of my college Data Science Club.
4+
->It detects number plates from the vehicle images provided to it.
5+
6+
# Modules Used
7+
->OpenCV
8+
->matplotlib
9+
->numpy
10+
->imutils
11+
-> easyocr
12+
13+
# Screenshot
14+
15+
![](Screenshots/Output.png)
Loading

Data Science Project/APNR/apnrmain.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import cv2
2+
from matplotlib import pyplot as plt
3+
import numpy as np
4+
import imutils
5+
import easyocr
6+
img = cv2.imread('NumberPlateImage/4.jpeg')
7+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
8+
plt.imshow(cv2.cvtColor(gray, cv2.COLOR_BGR2RGB))
9+
bfilter = cv2.bilateralFilter(gray, 11, 17, 17) #Noise reduction
10+
edged = cv2.Canny(bfilter, 30, 200) #Edge detection
11+
plt.imshow(cv2.cvtColor(edged, cv2.COLOR_BGR2RGB))
12+
keypoints = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
13+
contours = imutils.grab_contours(keypoints)
14+
contours = sorted(contours, key=cv2.contourArea, reverse=True)[:10]
15+
location = None
16+
for contour in contours:
17+
approx = cv2.approxPolyDP(contour, 10, True)
18+
if len(approx) == 4:
19+
location = approx
20+
break
21+
mask = np.zeros(gray.shape, np.uint8)
22+
new_image = cv2.drawContours(mask, [location], 0,255, -1)
23+
new_image = cv2.bitwise_and(img, img, mask=mask)
24+
plt.imshow(cv2.cvtColor(new_image, cv2.COLOR_BGR2RGB))
25+
(x,y) = np.where(mask==255)
26+
(x1, y1) = (np.min(x), np.min(y))
27+
(x2, y2) = (np.max(x), np.max(y))
28+
cropped_image = gray[x1:x2+1, y1:y2+1]
29+
plt.imshow(cv2.cvtColor(cropped_image, cv2.COLOR_BGR2RGB))
30+
reader = easyocr.Reader(['en'])
31+
result = reader.readtext(cropped_image)
32+
result
33+
text = result[0][-2]
34+
font = cv2.FONT_HERSHEY_SIMPLEX
35+
res = cv2.putText(img, text=text, org=(approx[0][0][0], approx[1][0][1]+60), fontFace=font, fontScale=1, color=(0,255,0), thickness=2, lineType=cv2.LINE_AA)
36+
res = cv2.rectangle(img, tuple(approx[0][0]), tuple(approx[2][0]), (0,255,0),3)
37+
cv2.imshow("Detected",cv2.cvtColor(res, cv2.COLOR_BGR2RGB))
38+
cv2.waitKey(0)
39+
cv2.destroyAllWindows()
40+
print("Detected Number:",text)

0 commit comments

Comments
 (0)