def face_recognize(self):
cap = cv2.VideoCapture(self.index)
face_cascade = cv2.CascadeClassifier(self.cascade)
'''
face_cascade: cascade is entered here for further use.
'''
while(True):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
'''
Converts coloured video to black and white(Grayscale).
'''
if np.any(face_cascade.detectMultiScale(gray, 1.3, 5)):
print("Cascade found")
self.dispatch('on_match')
cv2.destroyAllWindows()
for i in range(1, 5):
cv2.waitKey(1)
break
else:
print("Not recognized")
cv2.imshow('frame', frame)
#Comment the above statement not to show the camera screen
if cv2.waitKey(1) & 0xFF == ord('q'):
print("Forcefully Closed")
cv2.destroyAllWindows()
for i in range(1, 5):
cv2.waitKey(1)
break
cap.release()
评论列表
文章目录