Spaces:
Sleeping
Sleeping
Commit
•
68b6477
1
Parent(s):
67e882f
Update app.py
Browse files
app.py
CHANGED
@@ -16,53 +16,53 @@ def push_up_count_logic(nose, right_wrist, right_shoulder):
|
|
16 |
else:
|
17 |
return 0
|
18 |
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
mode=WebRtcMode.SENDRECV,
|
25 |
-
video_transformer_factory=None,
|
26 |
-
async_processing=True,
|
27 |
-
)
|
28 |
|
29 |
-
|
30 |
-
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
push_up_count = 0
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
41 |
-
nose = (100, 100)
|
42 |
-
right_wrist = (200, 200)
|
43 |
-
right_shoulder = (150, 150)
|
44 |
|
45 |
-
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
image,
|
55 |
-
f"Push-up count: {push_up_count}",
|
56 |
-
org,
|
57 |
-
font,
|
58 |
-
font_scale,
|
59 |
-
color,
|
60 |
-
thickness,
|
61 |
-
cv2.LINE_AA,
|
62 |
-
)
|
63 |
|
64 |
-
|
65 |
-
|
66 |
|
67 |
if __name__ == "__main__":
|
68 |
-
main()
|
|
|
16 |
else:
|
17 |
return 0
|
18 |
|
19 |
+
# Define initial values
|
20 |
+
push_up_start = 0
|
21 |
+
push_up_count = 0
|
22 |
|
23 |
+
def video_frame_callback(frame):
|
24 |
+
global push_up_start, push_up_count
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
# Dummy values for demonstration
|
27 |
+
nose = (100, 100)
|
28 |
+
right_wrist = (200, 200)
|
29 |
+
right_shoulder = (150, 150)
|
30 |
|
31 |
+
push_up_count += push_up_count_logic(nose, right_wrist, right_shoulder)
|
|
|
32 |
|
33 |
+
# Display the push-up count on the video frame
|
34 |
+
image = frame.to_ndarray(format="bgr24")
|
35 |
+
font = cv2.FONT_HERSHEY_SIMPLEX
|
36 |
+
org = (50, 100)
|
37 |
+
font_scale = 1
|
38 |
+
color = (255, 0, 0)
|
39 |
+
thickness = 2
|
40 |
+
image = cv2.putText(
|
41 |
+
image,
|
42 |
+
f"Push-up count: {push_up_count}",
|
43 |
+
org,
|
44 |
+
font,
|
45 |
+
font_scale,
|
46 |
+
color,
|
47 |
+
thickness,
|
48 |
+
cv2.LINE_AA,
|
49 |
+
)
|
50 |
|
51 |
+
return av.VideoFrame.from_ndarray(image, format="bgr24")
|
|
|
|
|
|
|
52 |
|
53 |
+
def main():
|
54 |
+
st.title("AI Push-up Counter")
|
55 |
|
56 |
+
webrtc_ctx = webrtc_streamer(
|
57 |
+
key="pushup",
|
58 |
+
mode=WebRtcMode.SENDRECV,
|
59 |
+
# video_transformer_factory=None,
|
60 |
+
video_frame_callback=video_frame_callback,
|
61 |
+
# async_processing=True,
|
62 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
if not webrtc_ctx.state.playing:
|
65 |
+
return
|
66 |
|
67 |
if __name__ == "__main__":
|
68 |
+
main()
|