Spaces:
Sleeping
Sleeping
Update process_frame.py
Browse files- process_frame.py +9 -11
process_frame.py
CHANGED
|
@@ -12,16 +12,12 @@ class ProcessFrame:
|
|
| 12 |
|
| 13 |
# self.thresholds
|
| 14 |
self.thresholds = thresholds
|
| 15 |
-
|
| 16 |
# Font type.
|
| 17 |
self.font = cv2.FONT_HERSHEY_SIMPLEX
|
| 18 |
-
|
| 19 |
# line type
|
| 20 |
self.linetype = cv2.LINE_AA
|
| 21 |
-
|
| 22 |
# set radius to draw arc
|
| 23 |
-
self.radius = 20
|
| 24 |
-
|
| 25 |
# Colors in BGR format.
|
| 26 |
self.COLORS = {
|
| 27 |
'blue' : (0, 127, 255),
|
|
@@ -36,7 +32,8 @@ class ProcessFrame:
|
|
| 36 |
}
|
| 37 |
|
| 38 |
# Dictionary to maintain the various landmark features.
|
| 39 |
-
self.dict_features = {}
|
|
|
|
| 40 |
self.left_features = {
|
| 41 |
'shoulder': 11,
|
| 42 |
'elbow' : 13,
|
|
@@ -57,18 +54,19 @@ class ProcessFrame:
|
|
| 57 |
'foot' : 32
|
| 58 |
}
|
| 59 |
|
|
|
|
| 60 |
self.dict_features['left'] = self.left_features
|
| 61 |
self.dict_features['right'] = self.right_features
|
| 62 |
self.dict_features['nose'] = 0
|
| 63 |
|
| 64 |
# For tracking counters and sharing states in and out of callbacks.
|
| 65 |
self.state_tracker = {
|
| 66 |
-
'state_seq': [],
|
| 67 |
|
| 68 |
-
'start_inactive_time': time.perf_counter(),
|
| 69 |
-
'start_inactive_time_front': time.perf_counter(),
|
| 70 |
-
'INACTIVE_TIME': 0.0,
|
| 71 |
-
'INACTIVE_TIME_FRONT': 0.0,
|
| 72 |
|
| 73 |
# 0 --> Bend Backwards, 1 --> Bend Forward, 2 --> Keep shin straight, 3 --> Deep squat
|
| 74 |
'DISPLAY_TEXT' : np.full((4,), False),
|
|
|
|
| 12 |
|
| 13 |
# self.thresholds
|
| 14 |
self.thresholds = thresholds
|
|
|
|
| 15 |
# Font type.
|
| 16 |
self.font = cv2.FONT_HERSHEY_SIMPLEX
|
|
|
|
| 17 |
# line type
|
| 18 |
self.linetype = cv2.LINE_AA
|
|
|
|
| 19 |
# set radius to draw arc
|
| 20 |
+
self.radius = 20 # Radius for drawing arcs
|
|
|
|
| 21 |
# Colors in BGR format.
|
| 22 |
self.COLORS = {
|
| 23 |
'blue' : (0, 127, 255),
|
|
|
|
| 32 |
}
|
| 33 |
|
| 34 |
# Dictionary to maintain the various landmark features.
|
| 35 |
+
self.dict_features = {} # Dictionary to store various landmark features based on body part names
|
| 36 |
+
# Define landmark feature names for left and right body sides
|
| 37 |
self.left_features = {
|
| 38 |
'shoulder': 11,
|
| 39 |
'elbow' : 13,
|
|
|
|
| 54 |
'foot' : 32
|
| 55 |
}
|
| 56 |
|
| 57 |
+
# Assign landmark feature dictionaries for left, right body sides and nose to main dictionary
|
| 58 |
self.dict_features['left'] = self.left_features
|
| 59 |
self.dict_features['right'] = self.right_features
|
| 60 |
self.dict_features['nose'] = 0
|
| 61 |
|
| 62 |
# For tracking counters and sharing states in and out of callbacks.
|
| 63 |
self.state_tracker = {
|
| 64 |
+
'state_seq': [], # Sequence of detected states
|
| 65 |
|
| 66 |
+
'start_inactive_time': time.perf_counter(), # Timer for front side inactivity
|
| 67 |
+
'start_inactive_time_front': time.perf_counter(), # Timer for side view inactivity
|
| 68 |
+
'INACTIVE_TIME': 0.0, # Total front side inactivity time
|
| 69 |
+
'INACTIVE_TIME_FRONT': 0.0, # Total side view inactivity time
|
| 70 |
|
| 71 |
# 0 --> Bend Backwards, 1 --> Bend Forward, 2 --> Keep shin straight, 3 --> Deep squat
|
| 72 |
'DISPLAY_TEXT' : np.full((4,), False),
|