Repository: roboflow/supervision
File: supervision/detection/line_counter.py (Python)

Code before:
        self.custom_in_text: str = custom_in_text
        self.custom_out_text: str = custom_out_text
        self.display_in_count: bool = display_in_count
        self.display_out_count: bool = display_out_count

    def _annotate_count(
        self,
        frame: np.ndarray,
        line_counter: LineZone,
        text: str,
        in_count: bool,
    ) -> None:
        """This method is drawing the text on the frame.

        Args:
            frame (np.ndarray): The image on which the text will be drawn.
            line_counter (LineCounter): The line counter
                that will be used to draw the line.
            text (str): The text that will be drawn.
            in_count (bool): Whether to display the in count or not.
        """
        (text_width, text_height), _ = cv2.getTextSize(
            text, cv2.FONT_HERSHEY_SIMPLEX, self.text_scale, self.text_thickness
        )

        text_x = (
            line_counter.vector.end.x + line_counter.vector.start.x - text_width
        ) / 2

        text_y = (
            line_counter.vector.end.y + line_counter.vector.start.y + text_height
        ) / 2

        if in_count:
            # if the text is an in count, we want to display it above the line
            text_y -= self.text_offset * text_height
        else:
            # if the text is an out count, we want to display it below the line
            text_y += self.text_offset * text_height

        text_background_rect = Rect(
            x=text_x,
            y=text_y - text_height,
            width=text_width,
            height=text_height,
        ).pad(padding=self.text_padding)

        cv2.rectangle(
            frame,
            text_background_rect.top_left.as_xy_int_tuple(),
            text_background_rect.bottom_right.as_xy_int_tuple(),

Review comment (suggestion):
I think we could add vector `center` property and hide this logic there.

```python
@dataclass
class Vector:
    start: Point
    end: Point

    @property
    def center(self) -> Point:
        pass
```

Code after:
        self.text_padding: int = text_padding
        self.custom_in_text: str = custom_in_text
        self.custom_out_text: str = custom_out_text
        self.display_in_count: bool = display_in_count
        self.display_out_count: bool = display_out_count

    def _annotate_count(
        self,
        frame: np.ndarray,
        center_text_anchor: Point,
        text: str,
        is_in_count: bool,
    ) -> None:
        """This method is drawing the text on the frame.

        Args:
            frame (np.ndarray): The image on which the text will be drawn.
            center_text_anchor: The center point that the text will be drawn.
            text (str): The text that will be drawn.
            is_in_count (bool): Whether to display the in count or out count.
        """
        _, text_height = cv2.getTextSize(
            text, cv2.FONT_HERSHEY_SIMPLEX, self.text_scale, self.text_thickness
        )[0]

        if is_in_count:
            center_text_anchor.y -= int(self.text_offset * text_height)
        else:
            center_text_anchor.y += int(self.text_offset * text_height)

        draw_text(
            scene=frame,
            text=text,
            text_anchor=center_text_anchor,
            text_color=self.text_color,
            text_scale=self.text_scale,
            text_thickness=self.text_thickness,
            text_padding=self.text_padding,
            background_color=self.color,
        )

    def annotate(self, frame: np.ndarray, line_counter: LineZone) -> np.ndarray:
        """
        Draws the line on the frame using the line_counter provided.

        Attributes:
            frame (np.ndarray): The image on which the line will be drawn.
            line_counter (LineCounter): The line counter
                that will be used to draw the line.

        Returns: