Args: boxes (Boxes, RotatedBoxes or ndarray): either a :class:`Boxes`, or an Nx4 numpy array of XYXY_ABS format for the N objects in a single image, or a :class:`RotatedBoxes`, or an Nx5 numpy array of (x_center, y_center, width, h
(
self,
*,
boxes=None,
labels=None,
masks=None,
keypoints=None,
assigned_colors=None,
alpha=0.5,
)
| 617 | return self.output |
| 618 | |
| 619 | def overlay_instances( |
| 620 | self, |
| 621 | *, |
| 622 | boxes=None, |
| 623 | labels=None, |
| 624 | masks=None, |
| 625 | keypoints=None, |
| 626 | assigned_colors=None, |
| 627 | alpha=0.5, |
| 628 | ): |
| 629 | """ |
| 630 | Args: |
| 631 | boxes (Boxes, RotatedBoxes or ndarray): either a :class:`Boxes`, |
| 632 | or an Nx4 numpy array of XYXY_ABS format for the N objects in a single image, |
| 633 | or a :class:`RotatedBoxes`, |
| 634 | or an Nx5 numpy array of (x_center, y_center, width, height, angle_degrees) format |
| 635 | for the N objects in a single image, |
| 636 | labels (list[str]): the text to be displayed for each instance. |
| 637 | masks (masks-like object): Supported types are: |
| 638 | |
| 639 | * :class:`detectron2.structures.PolygonMasks`, |
| 640 | :class:`detectron2.structures.BitMasks`. |
| 641 | * list[list[ndarray]]: contains the segmentation masks for all objects in one image. |
| 642 | The first level of the list corresponds to individual instances. The second |
| 643 | level to all the polygon that compose the instance, and the third level |
| 644 | to the polygon coordinates. The third level should have the format of |
| 645 | [x0, y0, x1, y1, ..., xn, yn] (n >= 3). |
| 646 | * list[ndarray]: each ndarray is a binary mask of shape (H, W). |
| 647 | * list[dict]: each dict is a COCO-style RLE. |
| 648 | keypoints (Keypoint or array like): an array-like object of shape (N, K, 3), |
| 649 | where the N is the number of instances and K is the number of keypoints. |
| 650 | The last dimension corresponds to (x, y, visibility or score). |
| 651 | assigned_colors (list[matplotlib.colors]): a list of colors, where each color |
| 652 | corresponds to each mask or box in the image. Refer to 'matplotlib.colors' |
| 653 | for full list of formats that the colors are accepted in. |
| 654 | Returns: |
| 655 | output (VisImage): image object with visualizations. |
| 656 | """ |
| 657 | num_instances = 0 |
| 658 | if boxes is not None: |
| 659 | boxes = self._convert_boxes(boxes) |
| 660 | num_instances = len(boxes) |
| 661 | if masks is not None: |
| 662 | masks = self._convert_masks(masks) |
| 663 | if num_instances: |
| 664 | assert len(masks) == num_instances |
| 665 | else: |
| 666 | num_instances = len(masks) |
| 667 | if keypoints is not None: |
| 668 | if num_instances: |
| 669 | assert len(keypoints) == num_instances |
| 670 | else: |
| 671 | num_instances = len(keypoints) |
| 672 | keypoints = self._convert_keypoints(keypoints) |
| 673 | if labels is not None: |
| 674 | assert len(labels) == num_instances |
| 675 | if assigned_colors is None: |
| 676 | assigned_colors = [random_color(rgb=True, maximum=1) for _ in range(num_instances)] |
no test coverage detected