mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-30 19:09:13 +01:00
91f7d67c5e
* Smarter Regions * Formatting * Cleanup * Fix motion region checking logic * Add database table and migration for regions * Update region grid on startup * Revert init delay change * Fix mypy * Move object related functions to util * Remove unused * Fix tests * Remove log * Update the region daily at 2 * Fix logic * Formatting * Initialize grid before starting processing frames * Move back to creating grid in main process * Formatting * Fixes * Formating * Fix region check * Accept all but true * Use regions grid for startup scan * Add clarifying comment * Fix new grid requests * Add tests * Delete stale region grids from DB
27 lines
708 B
Python
27 lines
708 B
Python
from unittest import TestCase, main
|
|
|
|
from frigate.util.object import box_overlaps, reduce_boxes
|
|
|
|
|
|
class TestBoxOverlaps(TestCase):
|
|
def test_overlap(self):
|
|
assert box_overlaps((100, 100, 200, 200), (50, 50, 150, 150))
|
|
|
|
def test_overlap_2(self):
|
|
assert box_overlaps((50, 50, 150, 150), (100, 100, 200, 200))
|
|
|
|
def test_no_overlap(self):
|
|
assert not box_overlaps((100, 100, 200, 200), (250, 250, 350, 350))
|
|
|
|
|
|
class TestReduceBoxes(TestCase):
|
|
def test_cluster(self):
|
|
clusters = reduce_boxes(
|
|
[(144, 290, 221, 459), (225, 178, 426, 341), (343, 105, 584, 250)]
|
|
)
|
|
assert len(clusters) == 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(verbosity=2)
|