Skip to content

Commit

Permalink
Merge 8d89d67 into af88d62
Browse files Browse the repository at this point in the history
  • Loading branch information
Tau-J authored Mar 13, 2023
2 parents af88d62 + 8d89d67 commit 94de007
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
8 changes: 7 additions & 1 deletion demo/bottomup_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ def process_one_image(args, img_path, pose_estimator, visualizer,
data_sample=results,
draw_gt=False,
draw_bbox=False,
show=args.show,
draw_heatmap=args.draw_heatmap,
show_kpt_idx=args.show_kpt_idx,
show=args.show,
wait_time=show_interval,
out_file=out_file,
kpt_score_thr=args.kpt_thr)
Expand Down Expand Up @@ -71,6 +72,11 @@ def parse_args():
'--draw-heatmap',
action='store_true',
help='Visualize the predicted heatmap')
parser.add_argument(
'--show-kpt-idx',
action='store_true',
default=False,
help='Whether to show the index of keypoints')
parser.add_argument(
'--kpt-thr', type=float, default=0.3, help='Keypoint score threshold')
parser.add_argument(
Expand Down
6 changes: 6 additions & 0 deletions demo/image_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def parse_args():
'--draw-heatmap',
action='store_true',
help='Visualize the predicted heatmap')
parser.add_argument(
'--show-kpt-idx',
action='store_true',
default=False,
help='Whether to show the index of keypoints')
parser.add_argument(
'--show',
action='store_true',
Expand Down Expand Up @@ -61,6 +66,7 @@ def main():
draw_gt=False,
draw_bbox=True,
draw_heatmap=args.draw_heatmap,
show_kpt_idx=args.show_kpt_idx,
show=args.show,
out_file=args.out_file)

Expand Down
6 changes: 6 additions & 0 deletions demo/topdown_demo_with_mmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def process_one_image(args, img_path, detector, pose_estimator, visualizer,
draw_gt=False,
draw_heatmap=args.draw_heatmap,
draw_bbox=args.draw_bbox,
show_kpt_idx=args.show_kpt_idx,
show=args.show,
wait_time=show_interval,
out_file=out_file,
Expand Down Expand Up @@ -115,6 +116,11 @@ def main():
action='store_true',
default=False,
help='Draw heatmap predicted by the model')
parser.add_argument(
'--show-kpt-idx',
action='store_true',
default=False,
help='Whether to show the index of keypoints')
parser.add_argument(
'--radius',
type=int,
Expand Down
18 changes: 15 additions & 3 deletions mmpose/visualization/local_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def _draw_instances_bbox(self, image: np.ndarray,
def _draw_instances_kpts(self,
image: np.ndarray,
instances: InstanceData,
kpt_score_thr: float = 0.3):
kpt_score_thr: float = 0.3,
show_kpt_idx: bool = False):
"""Draw keypoints and skeletons (optional) of GT or prediction.
Args:
Expand Down Expand Up @@ -276,6 +277,14 @@ def _draw_instances_kpts(self,
edge_colors=color,
alpha=transparency,
line_widths=self.radius)
if show_kpt_idx:
self.draw_texts(
str(kid),
kpt,
colors=color,
font_sizes=self.radius * 3,
vertical_alignments='bottom',
horizontal_alignments='center')

# draw links
if self.skeleton is not None and self.link_color is not None:
Expand Down Expand Up @@ -400,6 +409,7 @@ def add_datasample(self,
draw_pred: bool = True,
draw_heatmap: bool = False,
draw_bbox: bool = False,
show_kpt_idx: bool = False,
show: bool = False,
wait_time: float = 0,
out_file: Optional[str] = None,
Expand Down Expand Up @@ -448,7 +458,8 @@ def add_datasample(self,
# draw bboxes & keypoints
if 'gt_instances' in data_sample:
gt_img_data = self._draw_instances_kpts(
gt_img_data, data_sample.gt_instances, kpt_score_thr)
gt_img_data, data_sample.gt_instances, kpt_score_thr,
show_kpt_idx)
if draw_bbox:
gt_img_data = self._draw_instances_bbox(
gt_img_data, data_sample.gt_instances)
Expand All @@ -468,7 +479,8 @@ def add_datasample(self,
# draw bboxes & keypoints
if 'pred_instances' in data_sample:
pred_img_data = self._draw_instances_kpts(
pred_img_data, data_sample.pred_instances, kpt_score_thr)
pred_img_data, data_sample.pred_instances, kpt_score_thr,
show_kpt_idx)
if draw_bbox:
pred_img_data = self._draw_instances_bbox(
pred_img_data, data_sample.pred_instances)
Expand Down

0 comments on commit 94de007

Please # to comment.