-
Notifications
You must be signed in to change notification settings - Fork 490
/
Copy pathwebcam_detect.py
34 lines (30 loc) · 933 Bytes
/
webcam_detect.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
import cv2
import os
from keras.models import load_model
import numpy as np
from pygame import mixer
import time
from label_detect import classify_face
mixer.init()
sound = mixer.Sound('alarm.wav')
#face = cv2.CascadeClassifier('/media/preeth/Data/prajna_files/Drowsiness_detection/haar_cascade_files/haarcascade_frontalface_alt.xml')
cap = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_COMPLEX_SMALL
score=0
thicc=2
#faces = face.detectMultiScale(gray,minNeighbors=5,scaleFactor=1.1,minSize=(25,25))
while(True):
ret, frame = cap.read()
height,width = frame.shape[:2]
label = classify_face(frame)
if(label == 'with_mask'):
print("No Beep")
else:
sound.play()
print("Beep")
cv2.putText(frame,str(label),(100,height-20), font, 1,(255,255,255),1,cv2.LINE_AA)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()