Skip to content

Commit adfe037

Browse files
1
1 parent 5b23d23 commit adfe037

File tree

8 files changed

+196
-0
lines changed

8 files changed

+196
-0
lines changed

.gitignore

26 Bytes
Binary file not shown.

test_whole_app/gui/settings_dialog.py

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# modules/exercises/back_exercise.py
2+
3+
from modules.exercise_counter import SquatCounter
4+
from modules.gamification import Gamification
5+
from modules.angle_calculator import calculate_angle
6+
7+
class BackExercise:
8+
def __init__(self, angle_threshold_down=70, angle_threshold_up=110, min_hold_time=0.5):
9+
"""
10+
Initialize the BackExercise with specific parameters.
11+
12+
Parameters:
13+
- angle_threshold_down (float): Angle below which the back bend is considered 'down'.
14+
- angle_threshold_up (float): Angle above which the back is considered 'up'.
15+
- min_hold_time (float): Minimum time in seconds to hold a position before counting.
16+
"""
17+
self.counter = SquatCounter(angle_threshold_down, angle_threshold_up, min_hold_time)
18+
self.gamification = Gamification()
19+
20+
def process(self, landmarks):
21+
"""
22+
Process the landmarks to update the back counter and gamification.
23+
24+
Parameters:
25+
- landmarks (dict): Contains the x and y coordinates of upper_back, lower_back, and hips.
26+
27+
Returns:
28+
- reps (int): Total repetitions.
29+
- feedback (str): Feedback message.
30+
- points (int): Total points.
31+
- achievements (list): List of unlocked achievements.
32+
"""
33+
upper_back = landmarks['upper_back']
34+
lower_back = landmarks['lower_back']
35+
hips = landmarks['hips']
36+
37+
angle = calculate_angle(upper_back, lower_back, hips)
38+
39+
reps, feedback = self.counter.update(angle)
40+
41+
if feedback == "Good Rep":
42+
self.gamification.add_points(1)
43+
points = self.gamification.get_points()
44+
achievements = self.gamification.get_achievements().copy()
45+
else:
46+
points = self.gamification.get_points()
47+
achievements = self.gamification.get_achievements().copy()
48+
49+
return reps, feedback, points, achievements

test_whole_app/modules/exercises/__init__.py

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# modules/exercises/knee_exercise.py
2+
3+
from modules.exercise_counter import ExerciseCounter
4+
from modules.gamification import Gamification
5+
from modules.angle_calculator import calculate_angle
6+
7+
class KneeExercise:
8+
def __init__(self, angle_threshold_down=140, angle_threshold_up=160, min_hold_time=0.5):
9+
"""
10+
Initialize the KneeExercise with specific parameters.
11+
12+
Parameters:
13+
- angle_threshold_down (float): Angle below which the knee bend is considered 'down'.
14+
- angle_threshold_up (float): Angle above which the knee is considered 'up'.
15+
- min_hold_time (float): Minimum time in seconds to hold a position before counting.
16+
"""
17+
self.counter = ExerciseCounter(angle_threshold_down, angle_threshold_up, min_hold_time)
18+
self.gamification = Gamification()
19+
20+
def process(self, landmarks):
21+
"""
22+
Process the landmarks to update the squat counter and gamification.
23+
24+
Parameters:
25+
- landmarks (dict): Contains the x and y coordinates of hip, knee, and ankle.
26+
27+
Returns:
28+
- reps (int): Total repetitions.
29+
- feedback (str): Feedback message.
30+
- points (int): Total points.
31+
- achievements (list): List of unlocked achievements.
32+
"""
33+
hip = landmarks['hip']
34+
knee = landmarks['knee']
35+
ankle = landmarks['ankle']
36+
37+
angle = calculate_angle(hip, knee, ankle)
38+
39+
reps, feedback = self.counter.update(angle)
40+
41+
if feedback == "Good Rep":
42+
self.gamification.add_points(1)
43+
points = self.gamification.get_points()
44+
achievements = self.gamification.get_achievements().copy()
45+
else:
46+
points = self.gamification.get_points()
47+
achievements = self.gamification.get_achievements().copy()
48+
49+
return reps, feedback, points, achievements
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# modules/exercises/shoulder_exercise.py
2+
3+
from modules.exercise_counter import SquatCounter
4+
from modules.gamification import Gamification
5+
from modules.angle_calculator import calculate_angle
6+
7+
class ShoulderExercise:
8+
def __init__(self, angle_threshold_down=60, angle_threshold_up=120, min_hold_time=0.5):
9+
"""
10+
Initialize the ShoulderExercise with specific parameters.
11+
12+
Parameters:
13+
- angle_threshold_down (float): Angle below which the shoulder lift is considered 'down'.
14+
- angle_threshold_up (float): Angle above which the shoulder is considered 'up'.
15+
- min_hold_time (float): Minimum time in seconds to hold a position before counting.
16+
"""
17+
self.counter = SquatCounter(angle_threshold_down, angle_threshold_up, min_hold_time)
18+
self.gamification = Gamification()
19+
20+
def process(self, landmarks):
21+
"""
22+
Process the landmarks to update the shoulder counter and gamification.
23+
24+
Parameters:
25+
- landmarks (dict): Contains the x and y coordinates of shoulder, elbow, and wrist.
26+
27+
Returns:
28+
- reps (int): Total repetitions.
29+
- feedback (str): Feedback message.
30+
- points (int): Total points.
31+
- achievements (list): List of unlocked achievements.
32+
"""
33+
shoulder = landmarks['shoulder']
34+
elbow = landmarks['elbow']
35+
wrist = landmarks['wrist']
36+
37+
angle = calculate_angle(shoulder, elbow, wrist)
38+
39+
reps, feedback = self.counter.update(angle)
40+
41+
if feedback == "Good Rep":
42+
self.gamification.add_points(1)
43+
points = self.gamification.get_points()
44+
achievements = self.gamification.get_achievements().copy()
45+
else:
46+
points = self.gamification.get_points()
47+
achievements = self.gamification.get_achievements().copy()
48+
49+
return reps, feedback, points, achievements
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# modules/exercises/squat_exercise.py
2+
3+
from modules.exercise_counter import SquatCounter
4+
from modules.gamification import Gamification
5+
from modules.angle_calculator import calculate_angle
6+
7+
class SquatExercise:
8+
def __init__(self, angle_threshold_down=120, angle_threshold_up=160, min_hold_time=0.5):
9+
"""
10+
Initialize the SquatExercise with specific parameters.
11+
12+
Parameters:
13+
- angle_threshold_down (float): Angle below which the squat is considered 'down'.
14+
- angle_threshold_up (float): Angle above which the squat is considered 'up'.
15+
- min_hold_time (float): Minimum time in seconds to hold a position before counting.
16+
"""
17+
self.counter = SquatCounter(angle_threshold_down, angle_threshold_up, min_hold_time)
18+
self.gamification = Gamification()
19+
20+
def process(self, landmarks):
21+
"""
22+
Process the landmarks to update the squat counter and gamification.
23+
24+
Parameters:
25+
- landmarks (dict): Contains the x and y coordinates of hip, knee, and ankle.
26+
27+
Returns:
28+
- reps (int): Total repetitions.
29+
- feedback (str): Feedback message.
30+
- points (int): Total points.
31+
- achievements (list): List of unlocked achievements.
32+
"""
33+
hip = landmarks['hip']
34+
knee = landmarks['knee']
35+
ankle = landmarks['ankle']
36+
37+
angle = calculate_angle(hip, knee, ankle)
38+
39+
reps, feedback = self.counter.update(angle)
40+
41+
if feedback == "Good Rep":
42+
self.gamification.add_points(1)
43+
points = self.gamification.get_points()
44+
achievements = self.gamification.get_achievements().copy()
45+
else:
46+
points = self.gamification.get_points()
47+
achievements = self.gamification.get_achievements().copy()
48+
49+
return reps, feedback, points, achievements

0 commit comments

Comments
 (0)