Pratyush101 commited on
Commit
f8dfb38
·
verified ·
1 Parent(s): 4b114c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -13
app.py CHANGED
@@ -109,15 +109,10 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
109
  # Calculate angles
110
  angleKneeL = calculate_angle(hipL, kneeL, ankleL)
111
  angleHipL = calculate_angle(shoulderL, hipL, [hipL[0], 0])
112
- # # Hip angle
113
 
114
-
115
- # # Knee angle
116
- #Visualize of left leg knee joint
117
- cv2.putText(image, str(int(angleKneeL)), (170, 200), cv2.FONT_HERSHEY_SIMPLEX, 1.7, (255, 255, 255), 2, cv2.LINE_AA)
118
-
119
- # # Hip angle
120
- cv2.putText(image, str(int(angleHipL)), (0, 200), cv2.FONT_HERSHEY_SIMPLEX, 1.7, (255, 255, 255), 2, cv2.LINE_AA)
121
 
122
 
123
  if angleKneeL > 110 and stage == 'down':
@@ -130,8 +125,8 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
130
 
131
  # REP data
132
  # Setup Status box
133
- cv2.rectangle(image, (0,0), (275, 220), (127, 248, 236), -1)
134
- cv2.rectangle(image, (0, 3), (273, 217), (12, 85, 61), -1)
135
 
136
  cv2.putText(image, 'Left', (10, 22),
137
  cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2, cv2.LINE_AA)
@@ -147,9 +142,6 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
147
  cv2.putText(image, stage,
148
  (170, 70), cv2.FONT_HERSHEY_SIMPLEX, 1.7, (255, 255, 255), 2, cv2.LINE_AA)
149
 
150
- cv2.putText(image, 'HipL', (10, 150), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2, cv2.LINE_AA)
151
- cv2.putText(image, 'Knee', (180, 150),cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2, cv2.LINE_AA)
152
-
153
  mp_drawing.draw_landmarks(image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,mp_drawing.DrawingSpec(color=(255, 175, 0), thickness=2, circle_radius=2),mp_drawing.DrawingSpec(color=(0, 255, 200), thickness=2, circle_radius=2))
154
 
155
  result_queue.put(detections)
 
109
  # Calculate angles
110
  angleKneeL = calculate_angle(hipL, kneeL, ankleL)
111
  angleHipL = calculate_angle(shoulderL, hipL, [hipL[0], 0])
 
112
 
113
+ #Visualize of left leg
114
+ cv2.putText(image, str(angleHipL), tuple(np.multiply(angleHipL, [w, h]).astype(int)),cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2, cv2.LINE_AA)
115
+ cv2.putText(image, str(angleKneeL), tuple(np.multiply(angleKneeL, [w, h]).astype(int)),cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2, cv2.LINE_AA)
 
 
 
 
116
 
117
 
118
  if angleKneeL > 110 and stage == 'down':
 
125
 
126
  # REP data
127
  # Setup Status box
128
+ cv2.rectangle(image, (0,0), (275, 85), (127, 248, 236), -1)
129
+ cv2.rectangle(image, (0, 3), (273, 82), (12, 85, 61), -1)
130
 
131
  cv2.putText(image, 'Left', (10, 22),
132
  cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2, cv2.LINE_AA)
 
142
  cv2.putText(image, stage,
143
  (170, 70), cv2.FONT_HERSHEY_SIMPLEX, 1.7, (255, 255, 255), 2, cv2.LINE_AA)
144
 
 
 
 
145
  mp_drawing.draw_landmarks(image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,mp_drawing.DrawingSpec(color=(255, 175, 0), thickness=2, circle_radius=2),mp_drawing.DrawingSpec(color=(0, 255, 200), thickness=2, circle_radius=2))
146
 
147
  result_queue.put(detections)