Spaces:
Running
Running
Update pages/Camera.py
Browse files- pages/Camera.py +11 -19
pages/Camera.py
CHANGED
|
@@ -33,11 +33,9 @@ def main(config_path):
|
|
| 33 |
"""
|
| 34 |
)
|
| 35 |
|
| 36 |
-
result_queue = queue.Queue()
|
| 37 |
-
|
| 38 |
def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
|
| 39 |
img_rgb = frame.to_ndarray(format="rgb24")
|
| 40 |
-
|
| 41 |
return frame
|
| 42 |
|
| 43 |
webrtc_ctx = webrtc_streamer(
|
|
@@ -52,24 +50,18 @@ def main(config_path):
|
|
| 52 |
if not webrtc_ctx.state.playing:
|
| 53 |
continue
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
gesture = inference_thread.pred
|
| 62 |
-
if gesture not in ['no', '']:
|
| 63 |
-
if not gestures_deque:
|
| 64 |
-
gestures_deque.append(gesture)
|
| 65 |
-
elif gesture != gestures_deque[-1]:
|
| 66 |
-
gestures_deque.append(gesture)
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
unsafe_allow_html=True)
|
| 70 |
-
|
| 71 |
-
unsafe_allow_html=True)
|
| 72 |
-
print(gestures_deque)
|
| 73 |
|
| 74 |
if __name__ == "__main__":
|
| 75 |
asyncio.set_event_loop(asyncio.new_event_loop())
|
|
|
|
| 33 |
"""
|
| 34 |
)
|
| 35 |
|
|
|
|
|
|
|
| 36 |
def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
|
| 37 |
img_rgb = frame.to_ndarray(format="rgb24")
|
| 38 |
+
inference_thread.input_queue.append(cv2.resize(img_rgb, (224, 224)))
|
| 39 |
return frame
|
| 40 |
|
| 41 |
webrtc_ctx = webrtc_streamer(
|
|
|
|
| 50 |
if not webrtc_ctx.state.playing:
|
| 51 |
continue
|
| 52 |
|
| 53 |
+
gesture = inference_thread.pred
|
| 54 |
+
if gesture not in ['no', '']:
|
| 55 |
+
if not gestures_deque:
|
| 56 |
+
gestures_deque.append(gesture)
|
| 57 |
+
elif gesture != gestures_deque[-1]:
|
| 58 |
+
gestures_deque.append(gesture)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
text_output.markdown(f'<p style="font-size:20px"> Current gesture: {gesture}</p>',
|
| 61 |
+
unsafe_allow_html=True)
|
| 62 |
+
last_5_gestures.markdown(f'<p style="font-size:20px"> Last 5 gestures: {" ".join(gestures_deque)}</p>',
|
| 63 |
unsafe_allow_html=True)
|
| 64 |
+
print(gestures_deque)
|
|
|
|
|
|
|
| 65 |
|
| 66 |
if __name__ == "__main__":
|
| 67 |
asyncio.set_event_loop(asyncio.new_event_loop())
|