@@ -267,16 +267,17 @@ def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
267267 image = image * 255
268268
269269 for people in peoples :
270+ ### Pose Keyponts
270271 joint_pos = people ['joint_pos' ]
271- ## draw circles
272+ # draw circles
272273 for pos in joint_pos .items ():
273274 _ , pos_loc = pos # pos_id, pos_loc
274275 pos_loc = (int (pos_loc [0 ]), int (pos_loc [1 ]))
275276 cv2 .circle (image , center = pos_loc , radius = radius , color = (0 , 255 , 0 ), thickness = - 1 )
276277 # rr, cc = skimage.draw.circle(int(pos_loc[1]), int(pos_loc[0]), radius)
277278 # image[rr, cc] = [0, 255, 0]
278279
279- ## draw sketch
280+ # draw sketch
280281 # joint id (0 - r ankle, 1 - r knee, 2 - r hip, 3 - l hip, 4 - l knee,
281282 # 5 - l ankle, 6 - pelvis, 7 - thorax, 8 - upper neck,
282283 # 9 - head top, 10 - r wrist, 11 - r elbow, 12 - r shoulder,
@@ -322,6 +323,15 @@ def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
322323 thick )
323324 # rr, cc, val = skimage.draw.line_aa(int(joint_pos[start][1]), int(joint_pos[start][0]), int(joint_pos[end][1]), int(joint_pos[end][0]))
324325 # image[rr, cc] = line[1]
326+ ### Head
327+ head_rect = people ['head_rect' ]
328+ if head_rect : # if head exists
329+ cv2 .rectangle (
330+ image ,
331+ (int (head_rect [0 ]), int (head_rect [1 ])),
332+ (int (head_rect [2 ]), int (head_rect [3 ])), # up-left and botton-right
333+ [0 , 180 , 0 ],
334+ thick )
325335
326336 if save_name is not None :
327337 # cv2.imwrite(save_name, image)
0 commit comments