Make color hashable, use cache for label images

This commit is contained in:
LinasKo committed 2024-09-25 22:22:30 +03:00
1 parent 60c5292781
commit 6fbabeefff
2 files changed
+8

No files matched your search

+2
View File
@@ -1,3 +1,4 @@
from functools import lru_cache
import math
import warnings
from typing import Any, Dict, Iterable, Tuple
@@ -452,6 +453,7 @@ class LineZoneAnnotator:
return frame
@staticmethod
@lru_cache(maxsize=32)
def _make_count_label_image(
text: str,
*,
+6
View File
@@ -254,6 +254,12 @@ class Color:
@classproperty
def ROBOFLOW(cls) -> Color:
return Color.from_hex("#A351FB")
def __hash__(self):
return hash((self.r, self.g, self.b))
def __eq__(self, other):
return isinstance(other, Color) and self.r == other.r and self.g == other.g and self.b == other.b
@dataclass