Spaces:
Running
Running
Update pages/Camera.py
Browse files- pages/Camera.py +9 -16
pages/Camera.py
CHANGED
|
@@ -7,10 +7,9 @@ from streamlit_webrtc import WebRtcMode, webrtc_streamer
|
|
| 7 |
|
| 8 |
from utils import SLInference
|
| 9 |
|
| 10 |
-
|
| 11 |
logger = logging.getLogger(__name__)
|
| 12 |
|
| 13 |
-
def
|
| 14 |
"""
|
| 15 |
Main function of the app.
|
| 16 |
"""
|
|
@@ -27,9 +26,9 @@ def main():
|
|
| 27 |
inference_thread.start()
|
| 28 |
|
| 29 |
webrtc_ctx = webrtc_streamer(
|
| 30 |
-
key="video-
|
| 31 |
-
mode=WebRtcMode.
|
| 32 |
-
media_stream_constraints={"video": True},
|
| 33 |
)
|
| 34 |
|
| 35 |
gestures_deque = deque(maxlen=5)
|
|
@@ -40,9 +39,8 @@ def main():
|
|
| 40 |
text_output = st.empty()
|
| 41 |
last_5_gestures = st.empty()
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
if webrtc_ctx.video_receiver:
|
| 46 |
try:
|
| 47 |
video_frame = webrtc_ctx.video_receiver.get_frame(timeout=1)
|
| 48 |
except queue.Empty:
|
|
@@ -60,11 +58,6 @@ def main():
|
|
| 60 |
elif gesture != gestures_deque[-1]:
|
| 61 |
gestures_deque.append(gesture)
|
| 62 |
|
| 63 |
-
text_output.markdown(f'<p style="font-size:20px"> Current gesture: {gesture}</p>',
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
unsafe_allow_html=True)
|
| 67 |
-
print(gestures_deque)
|
| 68 |
-
|
| 69 |
-
if __name__ == "__main__":
|
| 70 |
-
main()
|
|
|
|
| 7 |
|
| 8 |
from utils import SLInference
|
| 9 |
|
|
|
|
| 10 |
logger = logging.getLogger(__name__)
|
| 11 |
|
| 12 |
+
def display():
|
| 13 |
"""
|
| 14 |
Main function of the app.
|
| 15 |
"""
|
|
|
|
| 26 |
inference_thread.start()
|
| 27 |
|
| 28 |
webrtc_ctx = webrtc_streamer(
|
| 29 |
+
key="video-sendrecv",
|
| 30 |
+
mode=WebRtcMode.SENDRECV, # Используем SENDRECV для отправки и получения видео
|
| 31 |
+
media_stream_constraints={"video": True, "audio": False}, # Включаем только видео
|
| 32 |
)
|
| 33 |
|
| 34 |
gestures_deque = deque(maxlen=5)
|
|
|
|
| 39 |
text_output = st.empty()
|
| 40 |
last_5_gestures = st.empty()
|
| 41 |
|
| 42 |
+
if webrtc_ctx.video_receiver:
|
| 43 |
+
while True:
|
|
|
|
| 44 |
try:
|
| 45 |
video_frame = webrtc_ctx.video_receiver.get_frame(timeout=1)
|
| 46 |
except queue.Empty:
|
|
|
|
| 58 |
elif gesture != gestures_deque[-1]:
|
| 59 |
gestures_deque.append(gesture)
|
| 60 |
|
| 61 |
+
text_output.markdown(f'<p style="font-size:20px"> Current gesture: {gesture}</p>', unsafe_allow_html=True)
|
| 62 |
+
last_5_gestures.markdown(f'<p style="font-size:20px"> Last 5 gestures: {" ".join(gestures_deque)}</p>', unsafe_allow_html=True)
|
| 63 |
+
print(gestures_deque)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|