Commit 347dce4b authored by Arne Gerdes's avatar Arne Gerdes

Eye Detection hinzugefügt

parent 2b725683
......@@ -8,6 +8,7 @@ detector = dlib.get_frontal_face_detector() # Face detector
detectors = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
predictor = dlib.shape_predictor(
"shape_predictor_68_face_landmarks.dat") # Landmark identifier. Set the filename to whatever you named the downloaded file
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
while True:
ret, frame = video_capture.read()
......@@ -26,6 +27,12 @@ while True:
thickness=2) # For each point, draw a red circle with thickness2 on the original frame
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2)
roi_gray = gray[y:y + h, x:x + w]
roi_color = frame[y:y + h, x:x + w]
eyes = eye_cascade.detectMultiScale(roi_gray)
for (ex, ey, ew, eh) in eyes:
cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 2)
cv2.imshow("image", frame) # Display the frame
if cv2.waitKey(1) & 0xFF == ord('q'): # Exit program when the user presses 'q'
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment