Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert face_landmark.py changes #163

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
Loading