Repository: roboflow/supervision
File: supervision/keypoint/annotators.py (Python)

Code before:
        self.text_scale: float = text_scale
        self.text_thickness: int = text_thickness
        self.text_padding: int = text_padding

    @staticmethod
    def get_text_bounding_box(
        text: str,
        font: int,
        text_scale: float,
        text_thickness: int,
        center_coordinates: Tuple[int, int],
    ) -> Tuple[int, int, int, int]:
        text_w, text_h = cv2.getTextSize(
            text=text,
            fontFace=font,
            fontScale=text_scale,
            thickness=text_thickness,
        )[0]
        center_x, center_y = center_coordinates
        return (
            center_x - text_w // 2,
            center_y - text_h // 2,
            center_x + text_w // 2,
            center_y + text_h // 2,
        )

    def annotate(
        self, scene: ImageType, key_points: KeyPoints, labels: List[str] = None
    ) -> ImageType:
        font = cv2.FONT_HERSHEY_SIMPLEX

        N, K, _ = key_points.xy.shape

        if N == 0:
            return scene

        anchors = key_points.xy.reshape(K * N, 2).astype(int)
        colors = (
            np.array(self.color * N)
            if isinstance(self.color, list)
            else np.array([self.color] * K * N)
        )
        labels = np.array(labels * N)

        mask = np.all(anchors != 0, axis=1)

        if np.all(mask == False):
            return scene

        anchors = anchors[mask]
        colors = colors[mask]

Review comment (suggestion):
Docs suggestion:

```
"""
        Annotates the given scene with skeleton vertices based on the provided key
        points, drawing boxes with rounded corners.

        Args:
            scene (ImageType): The image where bounding boxes will be drawn. `ImageType`
                is a flexible type, accepting either `numpy.ndarray` or
                `PIL.Image.Image`.
            key_points (KeyPoints): A collection of key points where each key point
                consists of x and y coordinates.
            labels (List[str], optional): A list of labels to be displayed on the
                annotated image. If not provided, keypoint indices will be used.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Example:
            ```python
            from inference import get_model
            import supervision as sv

            # Make sure to set the ROBOFLOW_API_KEY environment variable!

            image = ...

            model = get_model("coco-pose-detection/3")
            results = model.infer(image)[0]

            key_points = sv.KeyPoints.from_inference(results)

            annotator = sv.VertexLabelAnnotator(
                color=sv.Color.GREEN, radius=10)
            annotated_frame = annotator.annotate(
                scene=image.copy(),
                key_points=key_points
            )
            ```
        """
```

Code after:
        text_thickness: int = 1,
        text_padding: int = 10,
        border_radius: int = 0,
    ):
        """
        Args:
            color (Union[Color, List[Color]], optional): The color to use for each
                keypoint label. If a list is provided, the colors will be used in order
                for each keypoint.
            text_color (Color, optional): The color to use for the labels.
            text_scale (float, optional): The scale of the text.
            text_thickness (int, optional): The thickness of the text.
            text_padding (int, optional): The padding around the text.
            border_radius (int, optional): The radius of the rounded corners of the
                boxes. Set to a high value to produce circles.
        """
        self.border_radius: int = border_radius
        self.color: Union[Color, List[Color]] = color
        self.text_color: Color = text_color
        self.text_scale: float = text_scale
        self.text_thickness: int = text_thickness
        self.text_padding: int = text_padding

    def annotate(
        self, scene: ImageType, key_points: KeyPoints, labels: List[str] = None
    ) -> ImageType:
        """
        A class that draws labels of skeleton vertices on images. It uses specified key
            points to determine the locations where the vertices should be drawn.

        Args:
            scene (ImageType): The image where vertex labels will be drawn. `ImageType`
                is a flexible type, accepting either `numpy.ndarray` or
                `PIL.Image.Image`.
            key_points (KeyPoints): A collection of key points where each key point
                consists of x and y coordinates.
            labels (List[str], optional): A list of labels to be displayed on the
                annotated image. If not provided, keypoint indices will be used.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Example:
            ```python
            import supervision as sv

            image = ...
            key_points = sv.KeyPoints(...)

            vertex_label_annotator = sv.VertexLabelAnnotator(