forked from AnbuKumar-maker/AI-on-Jetson-Nano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFaceDetection
26 lines (21 loc) · 860 Bytes
/
FaceDetection
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
import cv2
print(cv2.__version__)
dispW=640
dispH=480
flip=2
#camSet='nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(dispW)+', height='+str(dispH)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink'
#cam= cv2.VideoCapture(camSet)
cam=cv2.VideoCapture(1)
face_cascade=cv2.CascadeClassifier('/home/anbu/Desktop/PyPro/cascade/face.xml')
while True:
ret, frame = cam.read()
gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
faces=face_cascade.detectMultiScale(gray,1.3,5)
for (x,y,w,h) in faces:
cv2.rectangle(frame, (x,y),(x+w,y+h),(0,0,255),4)
cv2.imshow('nanoCam',frame)
cv2.moveWindow('nanoCam',0,0)
if cv2.waitKey(1)==ord('q'):
break
cam.release()
cv2.destroyAllWindows()