Skip to content

Commit

Permalink
improved visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Pishchulin committed Jul 1, 2016
1 parent e5cc531 commit 90264f8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions python/pose/pose_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
_LOGGER = _logging.getLogger(__name__)


def _npcircle(image, cx, cy, radius, color):
def _npcircle(image, cx, cy, radius, color, transparency=0.0):
"""Draw a circle on an image using only numpy methods."""
radius = int(radius)
cx = int(cx)
cy = int(cy)
y, x = _np.ogrid[-radius: radius, -radius: radius]
index = x**2 + y**2 <= radius**2
image[cy-radius:cy+radius, cx-radius:cx+radius][index] = (
image[cy-radius:cy+radius, cx-radius:cx+radius][index].astype('float32') * 0.4 +
_np.array(color).astype('float32') * 0.6).astype('uint8')
image[cy-radius:cy+radius, cx-radius:cx+radius][index].astype('float32') * transparency +
_np.array(color).astype('float32') * (1.0 - transparency)).astype('uint8')


###############################################################################
Expand Down Expand Up @@ -123,12 +123,16 @@ def predict_pose_from(image_name,
_np.savez_compressed(out_name, pose=pose)
if visualize:
visim = image[:, :, ::-1].copy()
colors = [[255, 0, 0],[0, 255, 0],[0, 0, 255],[0,245,255],[255,131,250],[255,255,0],
[255, 0, 0],[0, 255, 0],[0, 0, 255],[0,245,255],[255,131,250],[255,255,0],
[0,0,0],[255,255,255]]
for p_idx in range(14):
_npcircle(visim,
pose[0, p_idx],
pose[1, p_idx],
5,
(255, 0, 0))
8,
colors[p_idx],
0.0)
vis_name = out_name + '_vis.png'
_scipy.misc.imsave(vis_name, visim)

Expand Down

0 comments on commit 90264f8

Please sign in to comment.