From 2805f41675ef85d9e5720fca31574b3fd1d16e2f Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:08:12 +0530 Subject: [PATCH 01/15] Updated annotators-core.py --- supervision/annotators/core.py | 68 ++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 1c0ad8af..dc22d7e8 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1613,6 +1613,7 @@ class TriangleAnnotator(BaseAnnotator): height: int = 10, position: Position = Position.TOP_CENTER, color_lookup: ColorLookup = ColorLookup.CLASS, + outline_thickness: int = 0 ): """ Args: @@ -1629,6 +1630,7 @@ class TriangleAnnotator(BaseAnnotator): self.height: int = height self.position: Position = position self.color_lookup: ColorLookup = color_lookup + self.outline_thickness : int = outline_thickness @convert_for_annotation_method def annotate( @@ -1669,27 +1671,53 @@ class TriangleAnnotator(BaseAnnotator): ![triangle-annotator-example](https://media.roboflow.com/ supervision-annotator-examples/triangle-annotator-example.png) """ - xy = detections.get_anchors_coordinates(anchor=self.position) - for detection_idx in range(len(detections)): - color = resolve_color( - color=self.color, - detections=detections, - detection_idx=detection_idx, - color_lookup=self.color_lookup - if custom_color_lookup is None - else custom_color_lookup, - ) - tip_x, tip_y = int(xy[detection_idx, 0]), int(xy[detection_idx, 1]) - vertices = np.array( - [ - [tip_x - self.base // 2, tip_y - self.height], - [tip_x + self.base // 2, tip_y - self.height], - [tip_x, tip_y], - ], - np.int32, - ) + if (self.outline_thickness): + for detection_idx in range(len(detections)): + x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int) + color = resolve_color( + color=self.color, + detections=detections, + detection_idx=detection_idx, + color_lookup=self.color_lookup + if custom_color_lookup is None + else custom_color_lookup, + ) - cv2.fillPoly(scene, [vertices], color.as_bgr()) + midpoint_top = ((x1 + x2) // 2, (y1 + y1) // 2) #midpoint((x1, y1), (x2, y1)) + + #shifted origin/centroid + cen2 = (midpoint_top[0], midpoint_top[1]-18) + tri_vertices = np.array([[cen2[0], cen2[1]+12], + [cen2[0]-10, cen2[1]-10], + [cen2[0]+10, cen2[1]-10]]) + + #upperhead pointer + cv2.drawContours(scene, [tri_vertices], -1, color.as_bgr(), thickness=-1) #BGR -->(0,255,232) + cv2.line(scene, ([cen2[0], cen2[1]+12]), ([cen2[0]-10, cen2[1]-10]), (0,0,0), self.outline_thickness) + cv2.line(scene, [cen2[0]-10, cen2[1]-10], [cen2[0]+10, cen2[1]-10], (0,0,0), self.outline_thickness) + cv2.line(scene, [cen2[0]+10, cen2[1]-10], [cen2[0], cen2[1]+12], (0,0,0), self.outline_thickness) + else: + xy = detections.get_anchors_coordinates(anchor=self.position) + for detection_idx in range(len(detections)): + color = resolve_color( + color=self.color, + detections=detections, + detection_idx=detection_idx, + color_lookup=self.color_lookup + if custom_color_lookup is None + else custom_color_lookup, + ) + tip_x, tip_y = int(xy[detection_idx, 0]), int(xy[detection_idx, 1]) + vertices = np.array( + [ + [tip_x - self.base // 2, tip_y - self.height], + [tip_x + self.base // 2, tip_y - self.height], + [tip_x, tip_y], + ], + np.int32, + ) + + cv2.fillPoly(scene, [vertices], color.as_bgr()) return scene From ff5709def25e80f12285e2a6491bd3b1596a89d4 Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:46:41 +0530 Subject: [PATCH 02/15] Updated annotators-core.py --- supervision/annotators/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index dc22d7e8..05a41361 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1613,7 +1613,7 @@ class TriangleAnnotator(BaseAnnotator): height: int = 10, position: Position = Position.TOP_CENTER, color_lookup: ColorLookup = ColorLookup.CLASS, - outline_thickness: int = 0 + outline_thickness: int = 0, ): """ Args: @@ -1630,7 +1630,7 @@ class TriangleAnnotator(BaseAnnotator): self.height: int = height self.position: Position = position self.color_lookup: ColorLookup = color_lookup - self.outline_thickness : int = outline_thickness + self.outline_thickness: int = outline_thickness @convert_for_annotation_method def annotate( From 6ea07a1c2abdf8a769fadffe7e8da133cf46de69 Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:11:52 +0530 Subject: [PATCH 03/15] Updated dot-annotator-core.py --- supervision/annotators/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 05a41361..dd585317 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -830,9 +830,10 @@ class DotAnnotator(BaseAnnotator): def __init__( self, color: Union[Color, ColorPalette] = ColorPalette.DEFAULT, - radius: int = 4, + radius: int = 5, position: Position = Position.CENTER, color_lookup: ColorLookup = ColorLookup.CLASS, + outer_thickness : int = 0 ): """ Args: @@ -847,6 +848,7 @@ class DotAnnotator(BaseAnnotator): self.radius: int = radius self.position: Position = position self.color_lookup: ColorLookup = color_lookup + self.outer_thickness = outer_thickness @convert_for_annotation_method def annotate( @@ -899,6 +901,7 @@ class DotAnnotator(BaseAnnotator): ) center = (int(xy[detection_idx, 0]), int(xy[detection_idx, 1])) cv2.circle(scene, center, self.radius, color.as_bgr(), -1) + cv2.circle(scene, center, self.radius, (0,0,0), self.outer_thickness) return scene From feeea38e6e45c97b3048705f0240a98ace80e2c2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 14:11:44 +0000 Subject: [PATCH 04/15] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto?= =?UTF-8?q?=20format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/annotators/core.py | 59 +++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index dd585317..b1f0793a 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -833,7 +833,7 @@ class DotAnnotator(BaseAnnotator): radius: int = 5, position: Position = Position.CENTER, color_lookup: ColorLookup = ColorLookup.CLASS, - outer_thickness : int = 0 + outer_thickness: int = 0, ): """ Args: @@ -901,7 +901,7 @@ class DotAnnotator(BaseAnnotator): ) center = (int(xy[detection_idx, 0]), int(xy[detection_idx, 1])) cv2.circle(scene, center, self.radius, color.as_bgr(), -1) - cv2.circle(scene, center, self.radius, (0,0,0), self.outer_thickness) + cv2.circle(scene, center, self.radius, (0, 0, 0), self.outer_thickness) return scene @@ -1674,7 +1674,7 @@ class TriangleAnnotator(BaseAnnotator): ![triangle-annotator-example](https://media.roboflow.com/ supervision-annotator-examples/triangle-annotator-example.png) """ - if (self.outline_thickness): + if self.outline_thickness: for detection_idx in range(len(detections)): x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int) color = resolve_color( @@ -1686,20 +1686,47 @@ class TriangleAnnotator(BaseAnnotator): else custom_color_lookup, ) - midpoint_top = ((x1 + x2) // 2, (y1 + y1) // 2) #midpoint((x1, y1), (x2, y1)) + midpoint_top = ( + (x1 + x2) // 2, + (y1 + y1) // 2, + ) # midpoint((x1, y1), (x2, y1)) - #shifted origin/centroid - cen2 = (midpoint_top[0], midpoint_top[1]-18) - tri_vertices = np.array([[cen2[0], cen2[1]+12], - [cen2[0]-10, cen2[1]-10], - [cen2[0]+10, cen2[1]-10]]) + # shifted origin/centroid + cen2 = (midpoint_top[0], midpoint_top[1] - 18) + tri_vertices = np.array( + [ + [cen2[0], cen2[1] + 12], + [cen2[0] - 10, cen2[1] - 10], + [cen2[0] + 10, cen2[1] - 10], + ] + ) - #upperhead pointer - cv2.drawContours(scene, [tri_vertices], -1, color.as_bgr(), thickness=-1) #BGR -->(0,255,232) - cv2.line(scene, ([cen2[0], cen2[1]+12]), ([cen2[0]-10, cen2[1]-10]), (0,0,0), self.outline_thickness) - cv2.line(scene, [cen2[0]-10, cen2[1]-10], [cen2[0]+10, cen2[1]-10], (0,0,0), self.outline_thickness) - cv2.line(scene, [cen2[0]+10, cen2[1]-10], [cen2[0], cen2[1]+12], (0,0,0), self.outline_thickness) - else: + # upperhead pointer + cv2.drawContours( + scene, [tri_vertices], -1, color.as_bgr(), thickness=-1 + ) # BGR -->(0,255,232) + cv2.line( + scene, + ([cen2[0], cen2[1] + 12]), + ([cen2[0] - 10, cen2[1] - 10]), + (0, 0, 0), + self.outline_thickness, + ) + cv2.line( + scene, + [cen2[0] - 10, cen2[1] - 10], + [cen2[0] + 10, cen2[1] - 10], + (0, 0, 0), + self.outline_thickness, + ) + cv2.line( + scene, + [cen2[0] + 10, cen2[1] - 10], + [cen2[0], cen2[1] + 12], + (0, 0, 0), + self.outline_thickness, + ) + else: xy = detections.get_anchors_coordinates(anchor=self.position) for detection_idx in range(len(detections)): color = resolve_color( @@ -1719,7 +1746,7 @@ class TriangleAnnotator(BaseAnnotator): ], np.int32, ) - + cv2.fillPoly(scene, [vertices], color.as_bgr()) return scene From e7de6859e935399464dd58f6fc43b9684d3c336e Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Wed, 19 Jun 2024 22:57:52 +0530 Subject: [PATCH 05/15] Updated annotation-core.py --- supervision/annotators/core.py | 66 ++++------------------------------ 1 file changed, 7 insertions(+), 59 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index b1f0793a..70aa55fe 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -830,10 +830,10 @@ class DotAnnotator(BaseAnnotator): def __init__( self, color: Union[Color, ColorPalette] = ColorPalette.DEFAULT, - radius: int = 5, + radius: int = 4, position: Position = Position.CENTER, color_lookup: ColorLookup = ColorLookup.CLASS, - outer_thickness: int = 0, + outline_thickness: int = 0, ): """ Args: @@ -848,7 +848,7 @@ class DotAnnotator(BaseAnnotator): self.radius: int = radius self.position: Position = position self.color_lookup: ColorLookup = color_lookup - self.outer_thickness = outer_thickness + self.outline_thickness = outline_thickness @convert_for_annotation_method def annotate( @@ -900,8 +900,8 @@ class DotAnnotator(BaseAnnotator): else custom_color_lookup, ) center = (int(xy[detection_idx, 0]), int(xy[detection_idx, 1])) + cv2.circle(scene, center, self.radius, (0, 0, 0), self.outline_thickness) cv2.circle(scene, center, self.radius, color.as_bgr(), -1) - cv2.circle(scene, center, self.radius, (0, 0, 0), self.outer_thickness) return scene @@ -1674,60 +1674,7 @@ class TriangleAnnotator(BaseAnnotator): ![triangle-annotator-example](https://media.roboflow.com/ supervision-annotator-examples/triangle-annotator-example.png) """ - if self.outline_thickness: - for detection_idx in range(len(detections)): - x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int) - color = resolve_color( - color=self.color, - detections=detections, - detection_idx=detection_idx, - color_lookup=self.color_lookup - if custom_color_lookup is None - else custom_color_lookup, - ) - - midpoint_top = ( - (x1 + x2) // 2, - (y1 + y1) // 2, - ) # midpoint((x1, y1), (x2, y1)) - - # shifted origin/centroid - cen2 = (midpoint_top[0], midpoint_top[1] - 18) - tri_vertices = np.array( - [ - [cen2[0], cen2[1] + 12], - [cen2[0] - 10, cen2[1] - 10], - [cen2[0] + 10, cen2[1] - 10], - ] - ) - - # upperhead pointer - cv2.drawContours( - scene, [tri_vertices], -1, color.as_bgr(), thickness=-1 - ) # BGR -->(0,255,232) - cv2.line( - scene, - ([cen2[0], cen2[1] + 12]), - ([cen2[0] - 10, cen2[1] - 10]), - (0, 0, 0), - self.outline_thickness, - ) - cv2.line( - scene, - [cen2[0] - 10, cen2[1] - 10], - [cen2[0] + 10, cen2[1] - 10], - (0, 0, 0), - self.outline_thickness, - ) - cv2.line( - scene, - [cen2[0] + 10, cen2[1] - 10], - [cen2[0], cen2[1] + 12], - (0, 0, 0), - self.outline_thickness, - ) - else: - xy = detections.get_anchors_coordinates(anchor=self.position) + xy = detections.get_anchors_coordinates(anchor=self.position) for detection_idx in range(len(detections)): color = resolve_color( color=self.color, @@ -1748,7 +1695,8 @@ class TriangleAnnotator(BaseAnnotator): ) cv2.fillPoly(scene, [vertices], color.as_bgr()) - + cv2.polylines(scene, [vertices], True, (0,0,0), thickness=self.outline_thickness) + return scene From 95308126c7388b6c35b6e910684c3278128520d2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:28:07 +0000 Subject: [PATCH 06/15] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto?= =?UTF-8?q?=20format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/annotators/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 70aa55fe..759d0bac 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1696,7 +1696,7 @@ class TriangleAnnotator(BaseAnnotator): cv2.fillPoly(scene, [vertices], color.as_bgr()) cv2.polylines(scene, [vertices], True, (0,0,0), thickness=self.outline_thickness) - + return scene From 900952acae8af10434d7e60eeb15868a4c773de7 Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:08:36 +0530 Subject: [PATCH 07/15] Modified annotators-core.py --- supervision/annotators/core.py | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 759d0bac..320666de 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1675,27 +1675,27 @@ class TriangleAnnotator(BaseAnnotator): supervision-annotator-examples/triangle-annotator-example.png) """ xy = detections.get_anchors_coordinates(anchor=self.position) - for detection_idx in range(len(detections)): - color = resolve_color( - color=self.color, - detections=detections, - detection_idx=detection_idx, - color_lookup=self.color_lookup - if custom_color_lookup is None - else custom_color_lookup, - ) - tip_x, tip_y = int(xy[detection_idx, 0]), int(xy[detection_idx, 1]) - vertices = np.array( - [ - [tip_x - self.base // 2, tip_y - self.height], - [tip_x + self.base // 2, tip_y - self.height], - [tip_x, tip_y], - ], - np.int32, - ) + for detection_idx in range(len(detections)): + color = resolve_color( + color=self.color, + detections=detections, + detection_idx=detection_idx, + color_lookup=self.color_lookup + if custom_color_lookup is None + else custom_color_lookup, + ) + tip_x, tip_y = int(xy[detection_idx, 0]), int(xy[detection_idx, 1]) + vertices = np.array( + [ + [tip_x - self.base // 2, tip_y - self.height], + [tip_x + self.base // 2, tip_y - self.height], + [tip_x, tip_y], + ], + np.int32, + ) - cv2.fillPoly(scene, [vertices], color.as_bgr()) - cv2.polylines(scene, [vertices], True, (0,0,0), thickness=self.outline_thickness) + cv2.fillPoly(scene, [vertices], color.as_bgr()) + cv2.polylines(scene, [vertices], True, (0,0,0), thickness=self.outline_thickness) return scene From 12722df65bfbd2dfe44d2cf233351b2c0d20c3d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:38:47 +0000 Subject: [PATCH 08/15] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto?= =?UTF-8?q?=20format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/annotators/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 320666de..548bd2e9 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1695,7 +1695,9 @@ class TriangleAnnotator(BaseAnnotator): ) cv2.fillPoly(scene, [vertices], color.as_bgr()) - cv2.polylines(scene, [vertices], True, (0,0,0), thickness=self.outline_thickness) + cv2.polylines( + scene, [vertices], True, (0, 0, 0), thickness=self.outline_thickness + ) return scene From 1489f82e0f50710310ab2f292427a0382b84862d Mon Sep 17 00:00:00 2001 From: Onuralp SEZER Date: Wed, 19 Jun 2024 20:43:44 +0300 Subject: [PATCH 09/15] =?UTF-8?q?docs:=20=F0=9F=93=9D=20outline=5Fthicknes?= =?UTF-8?q?s=20py=20docs=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onuralp SEZER --- supervision/annotators/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 548bd2e9..38f3b2b9 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -843,6 +843,7 @@ class DotAnnotator(BaseAnnotator): position (Position): The anchor position for placing the dot. color_lookup (ColorLookup): Strategy for mapping colors to annotations. Options are `INDEX`, `CLASS`, `TRACK`. + outline_thickness (int): Thickness of the outline of the dot. """ self.color: Union[Color, ColorPalette] = color self.radius: int = radius @@ -1627,6 +1628,7 @@ class TriangleAnnotator(BaseAnnotator): position (Position): The anchor position for placing the triangle. color_lookup (ColorLookup): Strategy for mapping colors to annotations. Options are `INDEX`, `CLASS`, `TRACK`. + outline_thickness (int): Thickness of the outline of the triangle. """ self.color: Union[Color, ColorPalette] = color self.base: int = base From a6222a065c09887c03e07103271463e48ba27f2c Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:44:30 +0530 Subject: [PATCH 10/15] Updated the Triangle_annotator and the Dot_annotator in the annotator-core.py --- supervision/annotators/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 38f3b2b9..596f23c4 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1697,9 +1697,8 @@ class TriangleAnnotator(BaseAnnotator): ) cv2.fillPoly(scene, [vertices], color.as_bgr()) - cv2.polylines( - scene, [vertices], True, (0, 0, 0), thickness=self.outline_thickness - ) + if self.outline_thickness: + cv2.polylines(scene, [vertices], True, (0,0,0), thickness=self.outline_thickness) return scene From ff9a63a68b4cc435d41e83f7a75df69af6511590 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:15:42 +0000 Subject: [PATCH 11/15] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto?= =?UTF-8?q?=20format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/annotators/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 596f23c4..14e2904d 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1698,7 +1698,9 @@ class TriangleAnnotator(BaseAnnotator): cv2.fillPoly(scene, [vertices], color.as_bgr()) if self.outline_thickness: - cv2.polylines(scene, [vertices], True, (0,0,0), thickness=self.outline_thickness) + cv2.polylines( + scene, [vertices], True, (0, 0, 0), thickness=self.outline_thickness + ) return scene From d821fca2af5689c77052a0e20ac86c38058ead6a Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:59:27 +0530 Subject: [PATCH 12/15] Updated the Triangle_annotator and the Dot_annotator in the annotator-core.py --- supervision/annotators/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 14e2904d..e5edd63a 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1701,7 +1701,6 @@ class TriangleAnnotator(BaseAnnotator): cv2.polylines( scene, [vertices], True, (0, 0, 0), thickness=self.outline_thickness ) - return scene From 0d0328ef22a6a00c0f98bf95e7de9130209ef785 Mon Sep 17 00:00:00 2001 From: Dripto Saha <73748916+dsaha21@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:12:42 +0530 Subject: [PATCH 13/15] Updated the Triangle_annotator and the Dot_annotator in the annotator-core.py file --- supervision/annotators/core.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index e5edd63a..fe826ee2 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -901,8 +901,13 @@ class DotAnnotator(BaseAnnotator): else custom_color_lookup, ) center = (int(xy[detection_idx, 0]), int(xy[detection_idx, 1])) - cv2.circle(scene, center, self.radius, (0, 0, 0), self.outline_thickness) - cv2.circle(scene, center, self.radius, color.as_bgr(), -1) + + if self.outline_thickness: + cv2.circle(scene, center, self.radius, (0,0,0), self.outline_thickness) + cv2.circle(scene, center, self.radius, color.as_bgr(), -1) + else: + cv2.circle(scene, center, self.radius, color.as_bgr(), -1) + return scene From 272a9cb35e48134b64149167b354117146460e8a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:43:32 +0000 Subject: [PATCH 14/15] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto?= =?UTF-8?q?=20format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/annotators/core.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index fe826ee2..984b0fa5 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -901,13 +901,15 @@ class DotAnnotator(BaseAnnotator): else custom_color_lookup, ) center = (int(xy[detection_idx, 0]), int(xy[detection_idx, 1])) - + if self.outline_thickness: - cv2.circle(scene, center, self.radius, (0,0,0), self.outline_thickness) + cv2.circle( + scene, center, self.radius, (0, 0, 0), self.outline_thickness + ) cv2.circle(scene, center, self.radius, color.as_bgr(), -1) else: cv2.circle(scene, center, self.radius, color.as_bgr(), -1) - + return scene From eec36152504dfce5831116af100e6c28e8aef6ed Mon Sep 17 00:00:00 2001 From: Onuralp SEZER Date: Thu, 20 Jun 2024 12:44:29 +0300 Subject: [PATCH 15/15] refactor: remove else statement for thickness in circle not needed Signed-off-by: Onuralp SEZER --- supervision/annotators/core.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 984b0fa5..17cf5795 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -902,14 +902,11 @@ class DotAnnotator(BaseAnnotator): ) center = (int(xy[detection_idx, 0]), int(xy[detection_idx, 1])) + cv2.circle(scene, center, self.radius, color.as_bgr(), -1) if self.outline_thickness: cv2.circle( scene, center, self.radius, (0, 0, 0), self.outline_thickness ) - cv2.circle(scene, center, self.radius, color.as_bgr(), -1) - else: - cv2.circle(scene, center, self.radius, color.as_bgr(), -1) - return scene