-
Notifications
You must be signed in to change notification settings - Fork 303
vis_keypoint --> vis_point #525
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from chainercv.visualizations.vis_bbox import vis_bbox # NOQA | ||
from chainercv.visualizations.vis_image import vis_image # NOQA | ||
from chainercv.visualizations.vis_keypoint import vis_keypoint # NOQA | ||
from chainercv.visualizations.vis_point import vis_point # NOQA | ||
from chainercv.visualizations.vis_semantic_segmentation import vis_semantic_segmentation # NOQA |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,32 +4,32 @@ | |
from chainercv.visualizations.vis_image import vis_image | ||
|
||
|
||
def vis_keypoint(img, keypoint, kp_mask=None, ax=None): | ||
"""Visualize keypoints in an image. | ||
def vis_point(img, point, mask=None, ax=None): | ||
"""Visualize points in an image. | ||
|
||
Example: | ||
|
||
>>> import chainercv | ||
>>> import matplotlib.pyplot as plot | ||
>>> dataset = chainercv.datasets.CUBKeypointDataset() | ||
>>> img, keypoint, kp_mask = dataset[0] | ||
>>> chainercv.visualizations.vis_keypoint(img, keypoint, kp_mask) | ||
>>> img, point, mask = dataset[0] | ||
>>> chainercv.visualizations.vis_point(img, point, mask) | ||
>>> plot.show() | ||
|
||
Args: | ||
img (~numpy.ndarray): An image of shape :math:`(3, height, width)`. | ||
This is in RGB format and the range of its value is | ||
:math:`[0, 255]`. This should be visualizable using | ||
:obj:`matplotlib.pyplot.imshow(img)` | ||
keypoint (~numpy.ndarray): An array with keypoint pairs whose shape is | ||
:math:`(K, 2)`, where :math:`K` is | ||
the number of keypoints in the array. | ||
point (~numpy.ndarray): An array of point coordinates whose shape is | ||
:math:`(P, 2)`, where :math:`P` is | ||
the number of points. | ||
The second axis corresponds to :math:`y` and :math:`x` coordinates | ||
of the keypoint. | ||
kp_mask (~numpy.ndarray, optional): A boolean array whose shape is | ||
:math:`(K,)`. If :math:`i` th index is :obj:`True`, the | ||
:math:`i` th keypoint is not displayed. If not specified, | ||
all keypoints in :obj:`keypoint` will be displayed. | ||
of the points. | ||
mask (~numpy.ndarray, optional): A boolean array whose shape is | ||
:math:`(P,)`. If :math:`i` th index is :obj:`True`, the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks |
||
:math:`i` th point is not displayed. If not specified, | ||
all points in :obj:`keypoint` will be displayed. | ||
ax (matplotlib.axes.Axes, optional): If provided, plot on this axis. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my bad |
||
|
||
Returns: | ||
|
@@ -42,18 +42,18 @@ def vis_keypoint(img, keypoint, kp_mask=None, ax=None): | |
ax = vis_image(img, ax=ax) | ||
|
||
_, H, W = img.shape | ||
n_kp = len(keypoint) | ||
n_point = len(point) | ||
|
||
if kp_mask is None: | ||
kp_mask = np.ones((n_kp,), dtype=np.bool) | ||
if mask is None: | ||
mask = np.ones((n_point,), dtype=np.bool) | ||
|
||
cm = plot.get_cmap('gist_rainbow') | ||
|
||
colors = [cm(1. * i / n_kp) for i in six.moves.range(n_kp)] | ||
colors = [cm(1. * i / n_point) for i in six.moves.range(n_point)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can write |
||
|
||
for i in range(n_kp): | ||
if kp_mask[i]: | ||
ax.scatter(keypoint[i][1], keypoint[i][0], c=colors[i], s=100) | ||
for i in range(n_point): | ||
if mask[i]: | ||
ax.scatter(point[i][1], point[i][0], c=colors[i], s=100) | ||
|
||
ax.set_xlim(left=0, right=W) | ||
ax.set_ylim(bottom=H - 1, top=0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional
in the type description may be against to our convention.c.f. https://github.com/chainer/chainercv/blob/master/chainercv/visualizations/vis_bbox.py#L27-L29