forked from dsutanto/chicken-counting-sukawarna-det
intial commit
This commit is contained in:
commit
a54a070ca9
49 files changed
+2960
No files matched your search
@@ -0,0 +1,40 @@
|
||||
"""Tests for mask polygon handling in DetectionTracker."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from chicken_counter.types import TrackObservation
|
||||
|
||||
|
||||
class TrackObservationMaskTests(unittest.TestCase):
|
||||
def test_track_observation_accepts_mask_polygon(self) -> None:
|
||||
poly = np.array([[10.0, 20.0], [30.0, 20.0], [30.0, 40.0]], dtype=np.float64)
|
||||
track = TrackObservation(
|
||||
track_id=1,
|
||||
class_id=0,
|
||||
confidence=0.9,
|
||||
bbox_xyxy=(10, 20, 30, 40),
|
||||
centroid=(20, 30),
|
||||
mask_polygon_xy=poly,
|
||||
)
|
||||
self.assertIsNotNone(track.mask_polygon_xy)
|
||||
self.assertEqual(track.mask_polygon_xy.shape, (3, 2))
|
||||
|
||||
def test_crop_offset_translation_pattern(self) -> None:
|
||||
"""Mirrors tracking.infer crop offset applied to mask polygons."""
|
||||
offset_x, offset_y = 100, 50
|
||||
local = np.array([[0.0, 0.0], [10.0, 0.0], [10.0, 10.0]], dtype=np.float64)
|
||||
full = local.copy()
|
||||
full[:, 0] += offset_x
|
||||
full[:, 1] += offset_y
|
||||
self.assertAlmostEqual(float(full[0, 0]), 100.0)
|
||||
self.assertAlmostEqual(float(full[0, 1]), 50.0)
|
||||
self.assertAlmostEqual(float(full[2, 0]), 110.0)
|
||||
self.assertAlmostEqual(float(full[2, 1]), 60.0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user