Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Feb 1, 2024
1 parent f6e808c commit 945c278
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
22 changes: 6 additions & 16 deletions examples/face_landmark/face_landmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,17 @@ async def frame_loop(video_stream: rtc.VideoStream) -> None:
argb_frame = None

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

View workflow job for this annotation

GitHub Actions / build

Ruff (F841)

examples/face_landmark/face_landmark.py:107:5: F841 Local variable `argb_frame` is assigned to but never used
cv2.namedWindow("livekit_video", cv2.WINDOW_AUTOSIZE)
cv2.startWindowThread()
async for frame in video_stream:
buffer = frame.buffer

if (
argb_frame is None
or argb_frame.width != buffer.width
or argb_frame.height != buffer.height
):
argb_frame = rtc.ArgbFrame.create(
rtc.VideoFormatType.FORMAT_ABGR, buffer.width, buffer.height
)

buffer.to_argb(argb_frame)
async for frame_event in video_stream:
buffer = frame_event.frame
buffer = buffer.convert(rtc.VideoBufferType.RGBA)

arr = np.frombuffer(argb_frame.data, dtype=np.uint8)
arr = arr.reshape((argb_frame.height, argb_frame.width, 4))
arr = np.frombuffer(buffer.data, dtype=np.uint8)
arr = arr.reshape((buffer.height, buffer.width, 4))
arr = cv2.cvtColor(arr, cv2.COLOR_RGBA2RGB)

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

detection_result = landmarker.detect_for_video(mp_image, frame.timestamp_us)
detection_result = landmarker.detect_for_video(mp_image, frame_event.timestamp_us)

draw_landmarks_on_image(arr, detection_result)

Expand Down
Binary file added examples/face_landmark/face_landmarker.task
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/publish_hue.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def draw_color_cycle(source: rtc.VideoSource):
arr.flat[2::4] = argb_color[2]
arr.flat[3::4] = argb_color[3]

frame = rtc.VideoFrame(WIDTH, HEIGHT, rtc.VideoBufferType.ARGB, argb_frame)
frame = rtc.VideoFrame(WIDTH, HEIGHT, rtc.VideoBufferType.RGBA, argb_frame)
source.capture_frame(frame)
hue = (hue + framerate / 3) % 1.0

Expand Down
2 changes: 1 addition & 1 deletion livekit-rtc/livekit/rtc/video_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def convert(
if resp.video_convert.error:
raise Exception(resp.video_convert.error)

return VideoFrame._from_owned_info(resp.video_convert)
return VideoFrame._from_owned_info(resp.video_convert.buffer)


def _component_info(
Expand Down

0 comments on commit 945c278

Please sign in to comment.