diff --git a/frigate/test/test_video.py b/frigate/test/test_video.py index c3e721c8c..094ef7437 100644 --- a/frigate/test/test_video.py +++ b/frigate/test/test_video.py @@ -81,7 +81,9 @@ class TestConfig(unittest.TestCase): def test_cluster_boundary(self): boxes = [(100, 100, 200, 200), (215, 215, 325, 325)] - boundary_boxes = [get_cluster_boundary(box) for box in boxes] + boundary_boxes = [ + get_cluster_boundary(box, self.min_region_size) for box in boxes + ] # save_cluster_boundary_image("bound", boxes, boundary_boxes) assert len(boundary_boxes) == 2 @@ -117,7 +119,7 @@ class TestConfig(unittest.TestCase): assert len(regions) == 2 def test_redundant_clusters(self): - boxes = [(100, 100, 200, 200), (215, 215, 325, 325)] + boxes = [(100, 100, 200, 200), (305, 305, 415, 415)] cluster_candidates = get_cluster_candidates( self.frame_shape, self.min_region_size, boxes diff --git a/frigate/video.py b/frigate/video.py index 294a281dc..f59e05d52 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -583,12 +583,12 @@ def detect( return detections -def get_cluster_boundary(box): - # compute the max region size for the current box (box is 20% of region) +def get_cluster_boundary(box, min_region): + # compute the max region size for the current box (box is 10% of region) box_width = box[2] - box[0] box_height = box[3] - box[1] - max_region_area = abs(box_width * box_height) / 0.2 - max_region_size = max(160, int(math.sqrt(max_region_area))) + max_region_area = abs(box_width * box_height) / 0.1 + max_region_size = max(min_region, int(math.sqrt(max_region_area))) centroid = (box_width / 2 + box[0], box_height / 2 + box[1]) @@ -617,7 +617,7 @@ def get_cluster_candidates(frame_shape, min_region, boxes): continue cluster = [current_index] used_boxes.append(current_index) - cluster_boundary = get_cluster_boundary(b) + cluster_boundary = get_cluster_boundary(b, min_region) # find all other boxes that fit inside the boundary for compare_index, compare_box in enumerate(boxes): if compare_index in used_boxes: