Spaces:
Sleeping
Sleeping
Update 5
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import cv2
|
| 3 |
import mediapipe as mp
|
|
@@ -712,11 +713,26 @@ st.markdown(
|
|
| 712 |
st.title("Workout Tracker")
|
| 713 |
st.markdown("Welcome to the **Workout Tracker App**! Select your desired workout below and receive real-time feedback as you exercise.")
|
| 714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
# Workout Selection
|
| 716 |
workout_option = st.radio("Select Your Workout:", ["Bicep Curl", "Lateral Raise", "Shoulder Press"])
|
| 717 |
|
| 718 |
# Start Button
|
| 719 |
if st.button("Start Workout"):
|
|
|
|
|
|
|
| 720 |
if workout_option == "Bicep Curl":
|
| 721 |
st.write("Launching Bicep Curl Tracker...")
|
| 722 |
bicep_curl()
|
|
@@ -730,3 +746,4 @@ if st.button("Start Workout"):
|
|
| 730 |
# Footer
|
| 731 |
st.markdown("---")
|
| 732 |
st.markdown("**Note**: Close the workout window or press 'q' in the camera feed to stop the workout.")
|
|
|
|
|
|
| 1 |
+
|
| 2 |
import streamlit as st
|
| 3 |
import cv2
|
| 4 |
import mediapipe as mp
|
|
|
|
| 713 |
st.title("Workout Tracker")
|
| 714 |
st.markdown("Welcome to the **Workout Tracker App**! Select your desired workout below and receive real-time feedback as you exercise.")
|
| 715 |
|
| 716 |
+
# Check webcam availability
|
| 717 |
+
def check_webcam():
|
| 718 |
+
try:
|
| 719 |
+
cap = cv2.VideoCapture(0)
|
| 720 |
+
if not cap.isOpened():
|
| 721 |
+
st.error("Webcam not detected! Please ensure a webcam is connected.")
|
| 722 |
+
return False
|
| 723 |
+
cap.release()
|
| 724 |
+
return True
|
| 725 |
+
except Exception as e:
|
| 726 |
+
st.error(f"Error accessing webcam: {e}")
|
| 727 |
+
return False
|
| 728 |
+
|
| 729 |
# Workout Selection
|
| 730 |
workout_option = st.radio("Select Your Workout:", ["Bicep Curl", "Lateral Raise", "Shoulder Press"])
|
| 731 |
|
| 732 |
# Start Button
|
| 733 |
if st.button("Start Workout"):
|
| 734 |
+
if not check_webcam():
|
| 735 |
+
st.stop()
|
| 736 |
if workout_option == "Bicep Curl":
|
| 737 |
st.write("Launching Bicep Curl Tracker...")
|
| 738 |
bicep_curl()
|
|
|
|
| 746 |
# Footer
|
| 747 |
st.markdown("---")
|
| 748 |
st.markdown("**Note**: Close the workout window or press 'q' in the camera feed to stop the workout.")
|
| 749 |
+
|