Skip to content

Commit d9e384a

Browse files
committed
improve visualization
1 parent 81bdc14 commit d9e384a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tensorlayer/visualize.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,25 +258,18 @@ def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
258258
# import skimage
259259
# don't change the original image, and avoid error https://stackoverflow.com/questions/30249053/python-opencv-drawing-errors-after-manipulating-array-with-numpy
260260
image = image.copy()
261-
radius = int(image.shape[1] / 500) + 1
262261

263262
imh, imw = image.shape[0:2]
264263
thick = int((imh + imw) // 430)
264+
# radius = int(image.shape[1] / 500) + 1
265+
radius = int(thick * 1.5)
265266

266267
if image.max() < 1:
267268
image = image * 255
268269

269270
for people in peoples:
270271
### Pose Keyponts
271272
joint_pos = people['joint_pos']
272-
# draw circles
273-
for pos in joint_pos.items():
274-
_, pos_loc = pos # pos_id, pos_loc
275-
pos_loc = (int(pos_loc[0]), int(pos_loc[1]))
276-
cv2.circle(image, center=pos_loc, radius=radius, color=(0, 255, 0), thickness=-1)
277-
# rr, cc = skimage.draw.circle(int(pos_loc[1]), int(pos_loc[0]), radius)
278-
# image[rr, cc] = [0, 255, 0]
279-
280273
# draw sketch
281274
# joint id (0 - r ankle, 1 - r knee, 2 - r hip, 3 - l hip, 4 - l knee,
282275
# 5 - l ankle, 6 - pelvis, 7 - thorax, 8 - upper neck,
@@ -323,6 +316,14 @@ def draw_mpii_people_to_image(image, peoples, save_name='image.png'):
323316
thick)
324317
# 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]))
325318
# image[rr, cc] = line[1]
319+
# draw circles
320+
for pos in joint_pos.items():
321+
_, pos_loc = pos # pos_id, pos_loc
322+
pos_loc = (int(pos_loc[0]), int(pos_loc[1]))
323+
cv2.circle(image, center=pos_loc, radius=radius, color=(200, 200, 200), thickness=-1)
324+
# rr, cc = skimage.draw.circle(int(pos_loc[1]), int(pos_loc[0]), radius)
325+
# image[rr, cc] = [0, 255, 0]
326+
326327
### Head
327328
head_rect = people['head_rect']
328329
if head_rect: # if head exists

0 commit comments

Comments
 (0)