-
Notifications
You must be signed in to change notification settings - Fork 0
/
anpr+frs.py
56 lines (40 loc) · 1.48 KB
/
anpr+frs.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import cv2
import numpy as np
import os
from pytesseract import pytesseract
import pandas as pd
frameWidth = 640
franeHeight = 480
plateCascade = cv2.CascadeClassifier("haarcascade_russian_plate_number.xml")
face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
minArea = 500
cap =cv2.VideoCapture("footage.mp4")
# cap.set(4,franeHeight)
# cap.set(10,150)
while True:
success , img = cap.read() #plate
imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #plate
#img = cv2.imread()
numberPlates = plateCascade .detectMultiScale(imgGray, 1.1, 4)
faces = face_cascade.detectMultiScale(imgGray,1.3, 5)
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)
imgRoi = img[y:y+h,x:x+w]
for (x,y,w,h) in faces:
area1 = w * h
if area1 > minArea:
cv2.rectangle(img, (x,y),(x+w,y+h),(0,255,0),3)
imgFace = img[y:y+h,x:x+w]
cv2.imshow('Frame',img)
count=0
if cv2.waitKey(10) & 0xFF==ord('q'):
cv2.imwrite("C:\\Users\\HP\\Desktop\\abc\\faces"+str(count)+".jpg",imgFace)
cv2.imwrite("C:\\Users\\HP\\Desktop\\abc\\photos"+str(count)+".jpg",imgRoi)
count = count + 1
cv2.rectangle(img,(0,200),(640,300),(0,255,0),cv2.FILLED)
cv2.waitKey(200)
break
cap.release()
cv2.destroyAllWindows()