Pratyush101 commited on
Commit
17fe806
·
verified ·
1 Parent(s): 768810e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -86,6 +86,16 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
86
  results = pose.process(image_rgb)
87
  landmarks = results.pose_landmarks.landmark if results.pose_landmarks else []
88
 
 
 
 
 
 
 
 
 
 
 
89
  if landmarks:
90
  hipL = [landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].x,
91
  landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].y]
@@ -113,6 +123,10 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
113
  cv2.rectangle(image, (0, 0), (500, 80), (245, 117, 16), -1)
114
  cv2.putText(image, overlay_text, (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2, cv2.LINE_AA)
115
 
 
 
 
 
116
  return av.VideoFrame.from_ndarray(image, format="bgr24")
117
 
118
  webrtc_streamer(
 
86
  results = pose.process(image_rgb)
87
  landmarks = results.pose_landmarks.landmark if results.pose_landmarks else []
88
 
89
+ # Corrected detection logic
90
+ detections = [
91
+ Detection(
92
+ class_id=0, # Assuming a generic class_id for pose detections
93
+ label="Pose",
94
+ score=0.5, # Full confidence as pose landmarks were detected
95
+ box=np.array([0, 0, image.shape[1], image.shape[0]]) # Full image as bounding box
96
+ ) if landmarks else []
97
+
98
+
99
  if landmarks:
100
  hipL = [landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].x,
101
  landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].y]
 
123
  cv2.rectangle(image, (0, 0), (500, 80), (245, 117, 16), -1)
124
  cv2.putText(image, overlay_text, (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2, cv2.LINE_AA)
125
 
126
+ 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))
127
+
128
+ result_queue.put(detections)
129
+
130
  return av.VideoFrame.from_ndarray(image, format="bgr24")
131
 
132
  webrtc_streamer(