Commit 2b725683 authored by Arne Gerdes's avatar Arne Gerdes

Mit FaceDetectionAndLandmark ist es nun moeglich ein Gesicht zu erkennen und...

Mit FaceDetectionAndLandmark ist es nun moeglich ein Gesicht zu erkennen und die Landmarks im Gesicht werden angezeigt
parent 8f86f61b
......@@ -5,6 +5,7 @@ import dlib
# Set up some required objects
video_capture = cv2.VideoCapture(0) # Webcam object
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
......@@ -13,6 +14,7 @@ while True:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
clahe_image = clahe.apply(gray)
faces = detectors.detectMultiScale(gray, 1.3, 5)
detections = detector(clahe_image, 1) # Detect the faces in the image
......@@ -22,7 +24,8 @@ while True:
for i in range(1, 68): # There are 68 landmark points on each face
cv2.circle(frame, (shape.part(i).x, shape.part(i).y), 1, (0, 0, 255),
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)
cv2.imshow("image", frame) # Display the frame
if cv2.waitKey(1) & 0xFF == ord('q'): # Exit program when the user presses 'q'
......
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