Skip to content

Commit

Permalink
Fix transparency parameter and window size (#68)
Browse files Browse the repository at this point in the history
Summary:
* Fixed missing alpha in instance masks of panoptic segmentation output
*(When changing alpha in demo/demo.py, the instance masks' alpha doesn't change otherwise)*
* Add namedWindow to handle the overlage window size
Pull Request resolved: #68

Differential Revision: D17926546

Pulled By: ppwwyyxx

fbshipit-source-id: 0ed302c9e6f662bb0bb90d667dbe0cbde8db845e
  • Loading branch information
kHarshit authored and facebook-github-bot committed Oct 15, 2019
1 parent bc4cf19 commit c869c9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

from predictor import VisualizationDemo

# constants
WINDOW_NAME = "COCO detections"


def setup_cfg(args):
# load config from file and command-line arguments
Expand Down Expand Up @@ -92,14 +95,16 @@ def get_parser():
out_filename = args.output
visualized_output.save(out_filename)
else:
cv2.imshow("COCO detections", visualized_output.get_image()[:, :, ::-1])
cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL)
cv2.imshow(WINDOW_NAME, visualized_output.get_image()[:, :, ::-1])
if cv2.waitKey(0) == 27:
break # esc to quit
elif args.webcam:
assert args.input is None, "Cannot have both --input and --webcam!"
cam = cv2.VideoCapture(0)
for vis in tqdm.tqdm(demo.run_on_video(cam)):
cv2.imshow("COCO detections", vis)
cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL)
cv2.imshow(WINDOW_NAME, vis)
if cv2.waitKey(1) == 27:
break # esc to quit
cv2.destroyAllWindows()
Expand Down Expand Up @@ -132,6 +137,7 @@ def get_parser():
if args.output:
output_file.write(vis_frame)
else:
cv2.namedWindow(basename, cv2.WINDOW_NORMAL)
cv2.imshow(basename, vis_frame)
if cv2.waitKey(1) == 27:
break # esc to quit
Expand Down
2 changes: 1 addition & 1 deletion detectron2/utils/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def draw_panoptic_seg_predictions(
colors = [random_color(rgb=True, maximum=1) for k in category_ids]
except AttributeError:
colors = None
self.overlay_instances(masks=masks, labels=labels, assigned_colors=colors)
self.overlay_instances(masks=masks, labels=labels, assigned_colors=colors, alpha=alpha)

return self.output

Expand Down

0 comments on commit c869c9f

Please sign in to comment.