Created
July 20, 2021 22:07
-
-
Save shoaibmehedi7/ee794baabe759046f4c2a48c9caa5cb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import mediapipe as mp | |
#Face Mesh | |
mp_face_mesh = mp.solutions.face_mesh | |
face_mesh = mp_face_mesh.FaceMesh() | |
#Image | |
image = cv2.imread("/home/python/OpenCV/faceMash/image1.jpg") | |
height, width, _ = image.shape | |
rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | |
#Facial landmarks | |
result = face_mesh.process(image) | |
for facial_landmarks in result.multi_face_landmarks: | |
for i in range(0, 468): | |
pt1 = facial_landmarks.landmark[i] | |
x = int(pt1.x * width) | |
y = int(pt1.y * height) | |
cv2.circle(image, (x,y), 2, (100,100,0), -1) | |
#cv2.putText(image, str(i), (x,y), 0,1,(0,0,0)) | |
cv2.imshow("Face Mesh detection", image) | |
cv2.waitKey(0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment