adjust cluster boundary to 10%

This commit is contained in:
Blake Blackshear 2023-06-11 06:48:21 -05:00
parent b1e16b5634
commit 5631f45311
2 changed files with 9 additions and 7 deletions

View File

@ -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

View File

@ -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: