-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber_plate_detection.py
More file actions
37 lines (30 loc) · 1.14 KB
/
Copy pathNumber_plate_detection.py
File metadata and controls
37 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import cv2
import numpy as np
frameWidth = 640 #Frame Width
franeHeight = 480 # Frame Height
plateCascade = cv2.CascadeClassifier("Sentinel_number_plate.xml")
minArea = 500
cap =cv2.VideoCapture(0)
cap.set(3,frameWidth)
cap.set(4,franeHeight)
cap.set(10,150)
count = 0
while True:
success , img = cap.read()
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
numberPlates = plateCascade .detectMultiScale(imgGray, 1.1, 4)
for (x, y, w, h) in numberPlates:
area = w*h
if area > minArea:
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
cv2.putText(img,"NumberPlate",(x,y-5),cv2.FONT_HERSHEY_COMPLEX,1,(0,0,255),2)
imgRoi = img[y:y+h,x:x+w]
cv2.imshow("ROI",imgRoi)
cv2.imshow("Result",img)
if cv2.waitKey(1) & 0xFF ==ord('s'):
cv2.imwrite("Images"+str(count)+".jpg",imgRoi)
cv2.rectangle(img,(0,200),(640,300),(0,255,0),cv2.FILLED)
cv2.putText(img,"Saved Successfully",(15,265),cv2.FONT_HERSHEY_DUPLEX,2,(255, 214, 51),3)
cv2.imshow("Result",img)
cv2.waitKey(500)
count+=1