Piarasingh85 commited on
Commit
98ac7ca
·
verified ·
1 Parent(s): 893ed32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -99,7 +99,6 @@ def classify_pose(landmarks, output_image, display=False):
99
  label = "Hands Under Feet Pose"
100
 
101
  # Check for Plank Pose
102
- #----------------------------------------------------------------------------------------------------------------
103
  # The body should be in a straight line from head to heels,
104
  # so the shoulder and hip angles should be close to 180 degrees
105
  if left_shoulder_angle > 160 and left_shoulder_angle < 200 and \
@@ -108,9 +107,17 @@ def classify_pose(landmarks, output_image, display=False):
108
  right_knee_angle > 160 and right_knee_angle < 200:
109
  label = "Plank Pose"
110
 
 
 
 
 
 
 
 
111
  return output_image, label
112
 
113
  def detect_and_classify_pose(input_image):
 
114
  results = pose.process(input_image)
115
  pose_classification = "No pose detected"
116
  if results.pose_landmarks:
 
99
  label = "Hands Under Feet Pose"
100
 
101
  # Check for Plank Pose
 
102
  # The body should be in a straight line from head to heels,
103
  # so the shoulder and hip angles should be close to 180 degrees
104
  if left_shoulder_angle > 160 and left_shoulder_angle < 200 and \
 
107
  right_knee_angle > 160 and right_knee_angle < 200:
108
  label = "Plank Pose"
109
 
110
+ # Update the color to green if pose is classified
111
+ if label != 'Unknown Pose':
112
+ color = (0, 255, 0)
113
+
114
+ # Write the label on the output image
115
+ cv2.putText(output_image, label, (10, 30), cv2.FONT_HERSHEY_PLAIN, 2, color, 2)
116
+
117
  return output_image, label
118
 
119
  def detect_and_classify_pose(input_image):
120
+ input_image = cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)
121
  results = pose.process(input_image)
122
  pose_classification = "No pose detected"
123
  if results.pose_landmarks: