From 7b22cfa7411d74a21390881b925e07416f662374 Mon Sep 17 00:00:00 2001 From: LinasKo Date: Wed, 25 Sep 2024 23:28:28 +0300 Subject: [PATCH] Bugfix: basic label would always have background box --- supervision/detection/line_zone.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/supervision/detection/line_zone.py b/supervision/detection/line_zone.py index 616a2673..d8107cca 100644 --- a/supervision/detection/line_zone.py +++ b/supervision/detection/line_zone.py @@ -419,6 +419,20 @@ class LineZoneAnnotator: text: str, is_in_count: bool, ) -> np.ndarray: + """ + Draw the count label on the frame. For example: "out: 7". + The label contains horizontal text and is not rotated. + + Args: + frame (np.ndarray): The entire scene, on which the label will be placed. + line_center (Point): The center of the line zone. + text (str): The text that will be drawn. + is_in_count (bool): Whether to display the in count (above line) + or out count (below line). + + Returns: + np.ndarray: The scene with the label drawn on it. + """ _, text_height = cv2.getTextSize( text, cv2.FONT_HERSHEY_SIMPLEX, self.text_scale, self.text_thickness )[0] @@ -436,7 +450,7 @@ class LineZoneAnnotator: text_scale=self.text_scale, text_thickness=self.text_thickness, text_padding=self.text_padding, - background_color=self.color, + background_color=self.color if self.display_text_box else None, ) return frame