-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhandstand_analyzer.py
More file actions
60 lines (48 loc) · 2 KB
/
handstand_analyzer.py
File metadata and controls
60 lines (48 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import streamlit as st
import cv2
import mediapipe as mp
import numpy as np
st.set_page_config(page_title="Handstand Analyzer", page_icon="🤸", layout="wide")
st.title("🤸 Handstand Analyzer")
st.write("Upload a handstand image to analyze your form")
mp_drawing = mp.solutions.drawing_utils
mp_pose = mp.solutions.pose
# Sidebar controls
with st.sidebar:
st.header("Settings")
detection_confidence = st.slider("Detection Confidence", 0.0, 1.0, 0.5, 0.05)
tracking_confidence = st.slider("Tracking Confidence", 0.0, 1.0, 0.5, 0.05)
uploaded_file = st.file_uploader("Upload handstand image", type=['jpg', 'jpeg', 'png'])
if uploaded_file:
col1, col2 = st.columns(2)
with col1:
st.subheader("Original Image")
st.image(uploaded_file)
# Process image
file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
image = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
with mp_pose.Pose(
static_image_mode=True,
model_complexity=0,
min_detection_confidence=detection_confidence,
) as pose:
results = pose.process(image_rgb)
with col2:
st.subheader("Pose Detection")
if results.pose_landmarks:
# Draw landmarks
annotated_image = image_rgb.copy()
mp_drawing.draw_landmarks(
annotated_image,
results.pose_landmarks,
mp_pose.POSE_CONNECTIONS,
mp_drawing.DrawingSpec(color=(245,117,66), thickness=2, circle_radius=2),
mp_drawing.DrawingSpec(color=(245,66,230), thickness=2, circle_radius=2)
)
st.image(annotated_image)
st.success("✅ Pose detected successfully!")
else:
st.error("❌ No pose detected. Try a clearer image.")
else:
st.info("👆 Upload an image to get started")