From 619abaa1f85d7905a4cc42979291d70e88af2830 Mon Sep 17 00:00:00 2001 From: Mike Odnis Date: Fri, 20 Oct 2023 18:53:12 -0400 Subject: [PATCH] Quick commit --- Advanced/AI/facial_landmark.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Advanced/AI/facial_landmark.py diff --git a/Advanced/AI/facial_landmark.py b/Advanced/AI/facial_landmark.py new file mode 100644 index 0000000..1c325f7 --- /dev/null +++ b/Advanced/AI/facial_landmark.py @@ -0,0 +1,29 @@ +import cv2 +import dlib + +predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") +detector = dlib.get_frontal_face_detector() + +cap = cv2.VideoCapture(0) + +while True: + ret, frame = cap.read() + if not ret: + break + + gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + faces = detector(gray) + + for face in faces: + landmarks = predictor(gray, face) + for n in range(68): + x, y = landmarks.part(n).x, landmarks.part(n).y + cv2.circle(frame, (x, y), 2, (0, 255, 0), -1) + + cv2.imshow("Facial Landmark Detection") + + if cv2.waitKey(1) & 0xFF == ord('q'): + break + +cap.release() +cv2.destroyAllWindows() \ No newline at end of file