Skip to content

Commit

Permalink
fix ptr align (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Feb 6, 2024
1 parent 8b319ba commit 24a90db
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 94 deletions.
23 changes: 0 additions & 23 deletions examples/face_landmark/face_landmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@

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 @@ -103,7 +89,6 @@ def draw_landmarks_on_image(rgb_image, detection_result):


async def frame_loop(video_stream: rtc.VideoStream) -> None:
landmarker = FaceLandmarker.create_from_options(options)
cv2.namedWindow("livekit_video", cv2.WINDOW_AUTOSIZE)
cv2.startWindowThread()
async for frame_event in video_stream:
Expand All @@ -112,19 +97,11 @@ 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(
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()
cv2.destroyAllWindows()


Expand Down
64 changes: 32 additions & 32 deletions livekit-rtc/livekit/rtc/_proto/video_frame_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions livekit-rtc/livekit/rtc/_proto/video_frame_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 24a90db

Please sign in to comment.