From f866fe046fe686b9b066d2b1fa059fc3e89d779c Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Wed, 23 Apr 2025 15:41:42 +0200 Subject: [PATCH] ready for tests --- supervision/annotators/utils.py | 6 ++++++ supervision/draw/color.py | 23 ++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/supervision/annotators/utils.py b/supervision/annotators/utils.py index ae4f8cdc..bada2a30 100644 --- a/supervision/annotators/utils.py +++ b/supervision/annotators/utils.py @@ -8,6 +8,10 @@ from supervision.draw.color import Color, ColorPalette from supervision.geometry.core import Position +PENDING_TRACK_COLOR = Color.GREY +PENDING_TRACK_ID = -1 + + class ColorLookup(Enum): """ Enumeration class to define strategies for mapping colors to annotations. @@ -136,6 +140,8 @@ def resolve_color( detection_idx=detection_idx, color_lookup=color_lookup, ) + if color_lookup == ColorLookup.TRACK and idx == PENDING_TRACK_ID: + return PENDING_TRACK_COLOR return get_color_by_index(color=color, idx=idx) diff --git a/supervision/draw/color.py b/supervision/draw/color.py index fe3ba900..e52df5a0 100644 --- a/supervision/draw/color.py +++ b/supervision/draw/color.py @@ -83,15 +83,16 @@ class Color: # Color(r=255, g=255, b=255) ``` - | Constant | Hex Code | RGB | - |------------|------------|------------------| - | `WHITE` | `#FFFFFF` | `(255, 255, 255)`| - | `BLACK` | `#000000` | `(0, 0, 0)` | - | `RED` | `#FF0000` | `(255, 0, 0)` | - | `GREEN` | `#00FF00` | `(0, 255, 0)` | - | `BLUE` | `#0000FF` | `(0, 0, 255)` | - | `YELLOW` | `#FFFF00` | `(255, 255, 0)` | - | `ROBOFLOW` | `#A351FB` | `(163, 81, 251)` | + | Constant | Hex Code | RGB | + |------------|------------|-------------------| + | `WHITE` | `#FFFFFF` | `(255, 255, 255)` | + | `BLACK` | `#000000` | `(0, 0, 0)` | + | `GREY` | `#808080` | `(128, 128, 128)` | + | `RED` | `#FF0000` | `(255, 0, 0)` | + | `GREEN` | `#00FF00` | `(0, 255, 0)` | + | `BLUE` | `#0000FF` | `(0, 0, 255)` | + | `YELLOW` | `#FFFF00` | `(255, 255, 0)` | + | `ROBOFLOW` | `#A351FB` | `(163, 81, 251)` | """ r: int @@ -235,6 +236,10 @@ class Color: def BLACK(cls) -> Color: return Color.from_hex("#000000") + @classproperty + def GREY(cls) -> Color: + return Color.from_hex("#808080") + @classproperty def RED(cls) -> Color: return Color.from_hex("#FF0000")