-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pose.py
More file actions
29 lines (24 loc) · 904 Bytes
/
Copy pathtest_pose.py
File metadata and controls
29 lines (24 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import cv2
import mediapipe as mp
import numpy as np
from pathlib import Path
img = cv2.imread('face.jpg')
BaseOptions = mp.tasks.BaseOptions
FaceLandmarker = mp.tasks.vision.FaceLandmarker
FaceLandmarkerOptions = mp.tasks.vision.FaceLandmarkerOptions
VisionRunningMode = mp.tasks.vision.RunningMode
options = FaceLandmarkerOptions(
base_options=BaseOptions(model_asset_path="models/face_landmarker.task"),
running_mode=VisionRunningMode.IMAGE,
num_faces=1,
output_facial_transformation_matrixes=True
)
landmarker = FaceLandmarker.create_from_options(options)
mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
result = landmarker.detect(mp_image)
if result.facial_transformation_matrixes:
m = result.facial_transformation_matrixes[0]
print("Matrix type:", type(m))
print(m)
else:
print("No faces or matrices detected.")