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

Code before:
            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(),
            self.color.as_bgr(),
            -1,
        )

        cv2.putText(
            frame,
            text,
            (int(text_x), int(text_y)),
            cv2.FONT_HERSHEY_SIMPLEX,
            self.text_scale,
            self.text_color.as_bgr(),
            self.text_thickness,
            cv2.LINE_AA,
        )

    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

Review comment (suggestion):
We could use `draw_text` here and remove the logic for drawing text and background. We already use it to draw the `PolygonZone` label. 

Code after:
            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:
            np.ndarray: The image with the line drawn on it.

        """
        cv2.line(
            frame,
            line_counter.vector.start.as_xy_int_tuple(),
            line_counter.vector.end.as_xy_int_tuple(),
            self.color.as_bgr(),
            self.thickness,
            lineType=cv2.LINE_AA,
            shift=0,
        )
        cv2.circle(
            frame,
            line_counter.vector.start.as_xy_int_tuple(),
            radius=5,
            color=self.text_color.as_bgr(),
            thickness=-1,
            lineType=cv2.LINE_AA,
        )
        cv2.circle(
            frame,