fffiloni commited on
Commit
06cf3c0
·
1 Parent(s): a2ecd8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -54,27 +54,31 @@ def predict(img):
54
  black_img = np.zeros((height, width, 3), np.uint8)
55
 
56
  # iterate through each person in the POSE_RESULTS data
57
- for person in pose_results:
58
  # get the keypoints for this person
59
  keypoints = person['keypoints']
60
 
61
  # draw lines between keypoints to form a skeleton
62
  skeleton = [(0,1), (1,2), (2,3), (3,4), (1,5), (5,6), (6,7), (1,8), (8,9), (9,10), (10,11), (8,12), (12,13), (13,14), (0,15), (15,17), (0,16), (16,18)]
63
  for i, j in skeleton:
 
 
64
  pt1 = (int(keypoints[i][0]), int(keypoints[i][1]))
65
  pt2 = (int(keypoints[j][0]), int(keypoints[j][1]))
66
  cv2.line(black_img, pt1, pt2, (255, 255, 255), thickness=2, lineType=cv2.LINE_AA)
67
 
68
  # draw circles at each keypoint
69
  for i in range(keypoints.shape[0]):
70
- if keypoints[i][2] > 0.0: # check if the keypoint is visible
71
- pt = (int(keypoints[i][0]), int(keypoints[i][1]))
72
- cv2.circle(black_img, pt, 3, (255, 255, 255), thickness=-1, lineType=cv2.LINE_AA)
 
73
 
74
 
75
  # write black_img to a jpg file
76
- cv2.imwrite("output.jpg", black_img)
77
  cv2.waitKey(0)
 
78
  cv2.destroyAllWindows()
79
 
80
  return vis_result, "output.jpg"
 
54
  black_img = np.zeros((height, width, 3), np.uint8)
55
 
56
  # iterate through each person in the POSE_RESULTS data
57
+ for person in POSE_RESULTS:
58
  # get the keypoints for this person
59
  keypoints = person['keypoints']
60
 
61
  # draw lines between keypoints to form a skeleton
62
  skeleton = [(0,1), (1,2), (2,3), (3,4), (1,5), (5,6), (6,7), (1,8), (8,9), (9,10), (10,11), (8,12), (12,13), (13,14), (0,15), (15,17), (0,16), (16,18)]
63
  for i, j in skeleton:
64
+ if keypoints[i][2] < 0.1 or keypoints[j][2] < 0.1:
65
+ continue
66
  pt1 = (int(keypoints[i][0]), int(keypoints[i][1]))
67
  pt2 = (int(keypoints[j][0]), int(keypoints[j][1]))
68
  cv2.line(black_img, pt1, pt2, (255, 255, 255), thickness=2, lineType=cv2.LINE_AA)
69
 
70
  # draw circles at each keypoint
71
  for i in range(keypoints.shape[0]):
72
+ if keypoints[i][2] < 0.1:
73
+ continue
74
+ pt = (int(keypoints[i][0]), int(keypoints[i][1]))
75
+ cv2.circle(black_img, pt, 3, (255, 255, 255), thickness=-1, lineType=cv2.LINE_AA)
76
 
77
 
78
  # write black_img to a jpg file
79
+
80
  cv2.waitKey(0)
81
+ cv2.imwrite("output.jpg", black_img)
82
  cv2.destroyAllWindows()
83
 
84
  return vis_result, "output.jpg"