Skip to content

Commit

Permalink
paint red haircrosses on estimated pts during validation
Browse files Browse the repository at this point in the history
Former-commit-id: 9890290f62b382e4158b08c44b07e1c9ef9ff52f
  • Loading branch information
Javier Ribera committed Oct 22, 2018
1 parent 16f59ef commit e369a3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 4 additions & 3 deletions object-locator/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,11 @@
titles=['(Validation) Image w/ output heatmap'],
window_ids=[5])
else:
# Send heatmap with a circle at the estimated centroids to Visdom
# Send heatmap with a cross at the estimated centroids to Visdom
img_with_x = utils.paint_circles(img=orig_img_w_heatmap_origsize,
points=centroids_wrt_orig,
color='red')
points=centroids_wrt_orig,
color='red',
crosshair=True )
log.image(imgs=[img_with_x],
titles=['(Validation) Image w/ output heatmap '
'and point estimations'],
Expand Down
15 changes: 12 additions & 3 deletions object-locator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def overlay_heatmap(img, map, colormap=matplotlib.cm.viridis):
return img_w_heatmap


def paint_circles(img, points, color='red'):
def paint_circles(img, points, color='red', crosshair=False):
"""
Paint points as circles on top of an image.
Expand All @@ -292,6 +292,9 @@ def paint_circles(img, points, color='red'):
First dimension must be color.
:param centroids: List of centroids in (y, x) format.
:param color: String of the color used to paint centroids.
Default: 'red'.
:param crosshair: Paint crosshair instead of circle.
Default: False.
:return: Image with painted circles centered on the points.
First dimension is be color.
"""
Expand All @@ -306,8 +309,14 @@ def paint_circles(img, points, color='red'):
points = points.round().astype(np.uint16)

img = np.moveaxis(img, 0, 2).copy()
for y, x in points:
img = cv2.circle(img, (x, y), 3, color, -1)
if not crosshair:
for y, x in points:
img = cv2.circle(img, (x, y), 3, color, -1)
else:
for y, x in points:
img = cv2.drawMarker(img,
(x, y),
color, cv2.MARKER_TILTED_CROSS, 9, 3, cv2.LINE_AA)
img = np.moveaxis(img, 2, 0)

return img

0 comments on commit e369a3b

Please sign in to comment.