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
)
| 575 | return self.output |
| 576 | |
| 577 | def overlay_instances( |
| 578 | self, |
| 579 | *, |
| 580 | boxes=None, |
| 581 | labels=None, |
| 582 | masks=None, |
| 583 | keypoints=None, |
| 584 | assigned_colors=None, |
| 585 | alpha=0.5 |
| 586 | ): |
| 587 | """ |
| 588 | Args: |
| 589 | boxes (Boxes, RotatedBoxes or ndarray): either a :class:`Boxes`, |
| 590 | or an Nx4 numpy array of XYXY_ABS format for the N objects in a single image, |
| 591 | or a :class:`RotatedBoxes`, |
| 592 | or an Nx5 numpy array of (x_center, y_center, width, height, angle_degrees) format |
| 593 | for the N objects in a single image, |
| 594 | labels (list[str]): the text to be displayed for each instance. |
| 595 | masks (masks-like object): Supported types are: |
| 596 | |
| 597 | * :class:`detectron2.structures.PolygonMasks`, |
| 598 | :class:`detectron2.structures.BitMasks`. |
| 599 | * list[list[ndarray]]: contains the segmentation masks for all objects in one image. |
| 600 | The first level of the list corresponds to individual instances. The second |
| 601 | level to all the polygon that compose the instance, and the third level |
| 602 | to the polygon coordinates. The third level should have the format of |
| 603 | [x0, y0, x1, y1, ..., xn, yn] (n >= 3). |
| 604 | * list[ndarray]: each ndarray is a binary mask of shape (H, W). |
| 605 | * list[dict]: each dict is a COCO-style RLE. |
| 606 | keypoints (Keypoint or array like): an array-like object of shape (N, K, 3), |
| 607 | where the N is the number of instances and K is the number of keypoints. |
| 608 | The last dimension corresponds to (x, y, visibility or score). |
| 609 | assigned_colors (list[matplotlib.colors]): a list of colors, where each color |
| 610 | corresponds to each mask or box in the image. Refer to 'matplotlib.colors' |
| 611 | for full list of formats that the colors are accepted in. |
| 612 | |
| 613 | Returns: |
| 614 | output (VisImage): image object with visualizations. |
| 615 | """ |
| 616 | num_instances = None |
| 617 | if boxes is not None: |
| 618 | boxes = self._convert_boxes(boxes) |
| 619 | num_instances = len(boxes) |
| 620 | if masks is not None: |
| 621 | masks = self._convert_masks(masks) |
| 622 | if num_instances: |
| 623 | assert len(masks) == num_instances |
| 624 | else: |
| 625 | num_instances = len(masks) |
| 626 | if keypoints is not None: |
| 627 | if num_instances: |
| 628 | assert len(keypoints) == num_instances |
| 629 | else: |
| 630 | num_instances = len(keypoints) |
| 631 | keypoints = self._convert_keypoints(keypoints) |
| 632 | if labels is not None: |
| 633 | assert len(labels) == num_instances |
| 634 | if assigned_colors is None: |