mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-06-21 03:41:55 +03:00
Merge 1c9396449e into 5003ab895c
This commit is contained in:
commit
b0fb7f2091
@ -3,6 +3,21 @@ import unittest
|
|||||||
from frigate.track.tracked_object import TrackedObjectAttribute
|
from frigate.track.tracked_object import TrackedObjectAttribute
|
||||||
|
|
||||||
|
|
||||||
|
class TestAttributeSlots(unittest.TestCase):
|
||||||
|
def test_attribute_uses_slots(self) -> None:
|
||||||
|
attribute = TrackedObjectAttribute(
|
||||||
|
("amazon", 0.8, (847, 242, 883, 255), 468, 2.77, (702, 134, 1050, 482))
|
||||||
|
)
|
||||||
|
# __slots__ means no per-instance __dict__
|
||||||
|
self.assertFalse(hasattr(attribute, "__dict__"))
|
||||||
|
# all declared fields are still populated and readable
|
||||||
|
self.assertEqual(attribute.label, "amazon")
|
||||||
|
self.assertEqual(attribute.region, (702, 134, 1050, 482))
|
||||||
|
# setting an undeclared attribute must raise (catches accidental drift)
|
||||||
|
with self.assertRaises(AttributeError):
|
||||||
|
attribute.unexpected = 1
|
||||||
|
|
||||||
|
|
||||||
class TestAttribute(unittest.TestCase):
|
class TestAttribute(unittest.TestCase):
|
||||||
def test_overlapping_object_selection(self) -> None:
|
def test_overlapping_object_selection(self) -> None:
|
||||||
attribute = TrackedObjectAttribute(
|
attribute = TrackedObjectAttribute(
|
||||||
|
|||||||
@ -574,6 +574,8 @@ def zone_filtered(obj: TrackedObject, object_config: dict[str, FilterConfig]) ->
|
|||||||
|
|
||||||
|
|
||||||
class TrackedObjectAttribute:
|
class TrackedObjectAttribute:
|
||||||
|
__slots__ = ("label", "score", "box", "area", "ratio", "region")
|
||||||
|
|
||||||
def __init__(self, raw_data: tuple) -> None:
|
def __init__(self, raw_data: tuple) -> None:
|
||||||
self.label = raw_data[0]
|
self.label = raw_data[0]
|
||||||
self.score = raw_data[1]
|
self.score = raw_data[1]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user