Skip to content

Commit

Permalink
revert face_landmark.py changes (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Feb 6, 2024
1 parent f4a1d16 commit 0a8bdde
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/face_landmark/face_landmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@

tasks = set()

# You can download a face landmark model file from https://developers.google.com/mediapipe/solutions/vision/face_landmarker#models
model_file = "face_landmarker.task"
model_path = os.path.dirname(os.path.realpath(__file__)) + "/" + model_file

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=model_path),
running_mode=VisionRunningMode.VIDEO,
)


async def main(room: rtc.Room) -> None:
video_stream = None
Expand Down Expand Up @@ -97,11 +111,19 @@ async def frame_loop(video_stream: rtc.VideoStream) -> None:
arr = np.frombuffer(buffer.data, dtype=np.uint8)
arr = arr.reshape((buffer.height, buffer.width, 3))

mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=arr)
detection_result = landmarker.detect_for_video(

Check failure on line 115 in examples/face_landmark/face_landmark.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F821)

examples/face_landmark/face_landmark.py:115:28: F821 Undefined name `landmarker`
mp_image, frame_event.timestamp_us
)

draw_landmarks_on_image(arr, detection_result)

arr = cv2.cvtColor(arr, cv2.COLOR_RGB2BGR)
cv2.imshow("livekit_video", arr)
if cv2.waitKey(1) & 0xFF == ord("q"):
break

landmarker.close()

Check failure on line 126 in examples/face_landmark/face_landmark.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F821)

examples/face_landmark/face_landmark.py:126:5: F821 Undefined name `landmarker`
cv2.destroyAllWindows()


Expand Down

0 comments on commit 0a8bdde

Please sign in to comment.