pn23 commited on
Commit
bb160cb
·
verified ·
1 Parent(s): 61bd756

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -12
app.py CHANGED
@@ -1,6 +1,9 @@
1
  import streamlit as st
2
  import numpy as np
3
  import cv2
 
 
 
4
 
5
  title = st.title("Welcome to Therapute")
6
 
@@ -19,15 +22,27 @@ st.success("Success")
19
 
20
 
21
 
22
-
23
- st.title("Webcam Live Feed")
24
- run = st.checkbox('Run')
25
- FRAME_WINDOW = st.image([])
26
- camera = cv2.VideoCapture(0)
27
-
28
- while run:
29
- _, frame = camera.read()
30
- frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
31
- FRAME_WINDOW.image(frame)
32
- else:
33
- st.write('Stopped')
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import numpy as np
3
  import cv2
4
+ import av
5
+ import mediapipe as mp
6
+ from streamlit_webrtc import webrtc_streamer, WebRtcMode, RTCConfiguration
7
 
8
  title = st.title("Welcome to Therapute")
9
 
 
22
 
23
 
24
 
25
+ RTC_CONFIGURATION = RTCConfiguration(
26
+ {"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}
27
+ )
28
+ webrtc_ctx = webrtc_streamer(
29
+ key="TEST",
30
+ mode=WebRtcMode.SENDRECV,
31
+ rtc_configuration=RTC_CONFIGURATION,
32
+ media_stream_constraints={"video": True, "audio": False},
33
+ async_processing=True,
34
+ )
35
+
36
+ class VideoProcessor:
37
+ def recv(self, frame):
38
+ img = frame.to_ndarray(format="bgr24")
39
+ # img = process(img)
40
+ return av.VideoFrame.from_ndarray(img, format="bgr24")
41
+ webrtc_ctx = webrtc_streamer(
42
+ key="WYH",
43
+ mode=WebRtcMode.SENDRECV,
44
+ rtc_configuration=RTC_CONFIGURATION,
45
+ media_stream_constraints={"video": True, "audio": False},
46
+ video_processor_factory=VideoProcessor,
47
+ async_processing=True,
48
+ )