diff --git a/frigate/test/test_video.py b/frigate/test/test_video.py index cba63c950..938e2f2c9 100644 --- a/frigate/test/test_video.py +++ b/frigate/test/test_video.py @@ -148,8 +148,8 @@ class TestRegion(unittest.TestCase): def test_combine_boxes(self): boxes = [ - (460, 0, 561, 144), - (565, 0, 586, 71), + (480, 0, 540, 128), + (536, 0, 558, 99), ] # boundary_boxes = [get_cluster_boundary(box) for box in boxes] @@ -167,8 +167,32 @@ class TestRegion(unittest.TestCase): # save_clusters_image("combine", boxes, cluster_candidates, regions) assert len(regions) == 1 + def test_dont_combine_smaller_boxes(self): + boxes = [ + (460, 0, 561, 144), + (565, 0, 586, 71), + ] + + # boundary_boxes = [get_cluster_boundary(box) for box in boxes] + # save_cluster_boundary_image("combine_bound", boxes, boundary_boxes) + + cluster_candidates = get_cluster_candidates( + self.frame_shape, self.min_region_size, boxes + ) + + regions = [ + get_cluster_region(self.frame_shape, self.min_region_size, candidate, boxes) + for candidate in cluster_candidates + ] + + # save_clusters_image("combine", boxes, cluster_candidates, regions) + assert len(regions) == 2 + def test_dont_combine_boxes(self): - boxes = [(460, 0, 532, 129), (586, 0, 606, 46)] + boxes = [ + (460, 0, 532, 129), + (586, 0, 606, 46), + ] # boundary_boxes = [get_cluster_boundary(box) for box in boxes] # save_cluster_boundary_image("dont_combine_bound", boxes, boundary_boxes) diff --git a/frigate/util/object.py b/frigate/util/object.py index 0bf7ea179..862ee3fe2 100644 --- a/frigate/util/object.py +++ b/frigate/util/object.py @@ -414,7 +414,7 @@ def get_cluster_region(frame_shape, min_region, cluster, boxes): max_x = max(boxes[b][2], max_x) max_y = max(boxes[b][3], max_y) return calculate_region( - frame_shape, min_x, min_y, max_x, max_y, min_region, multiplier=1.2 + frame_shape, min_x, min_y, max_x, max_y, min_region, multiplier=1.35 )