mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 10:45:21 +03:00
adjust cluster boundary to 10%
This commit is contained in:
parent
b1e16b5634
commit
5631f45311
@ -81,7 +81,9 @@ class TestConfig(unittest.TestCase):
|
|||||||
|
|
||||||
def test_cluster_boundary(self):
|
def test_cluster_boundary(self):
|
||||||
boxes = [(100, 100, 200, 200), (215, 215, 325, 325)]
|
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)
|
# save_cluster_boundary_image("bound", boxes, boundary_boxes)
|
||||||
assert len(boundary_boxes) == 2
|
assert len(boundary_boxes) == 2
|
||||||
@ -117,7 +119,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
assert len(regions) == 2
|
assert len(regions) == 2
|
||||||
|
|
||||||
def test_redundant_clusters(self):
|
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(
|
cluster_candidates = get_cluster_candidates(
|
||||||
self.frame_shape, self.min_region_size, boxes
|
self.frame_shape, self.min_region_size, boxes
|
||||||
|
|||||||
@ -583,12 +583,12 @@ def detect(
|
|||||||
return detections
|
return detections
|
||||||
|
|
||||||
|
|
||||||
def get_cluster_boundary(box):
|
def get_cluster_boundary(box, min_region):
|
||||||
# compute the max region size for the current box (box is 20% of region)
|
# compute the max region size for the current box (box is 10% of region)
|
||||||
box_width = box[2] - box[0]
|
box_width = box[2] - box[0]
|
||||||
box_height = box[3] - box[1]
|
box_height = box[3] - box[1]
|
||||||
max_region_area = abs(box_width * box_height) / 0.2
|
max_region_area = abs(box_width * box_height) / 0.1
|
||||||
max_region_size = max(160, int(math.sqrt(max_region_area)))
|
max_region_size = max(min_region, int(math.sqrt(max_region_area)))
|
||||||
|
|
||||||
centroid = (box_width / 2 + box[0], box_height / 2 + box[1])
|
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
|
continue
|
||||||
cluster = [current_index]
|
cluster = [current_index]
|
||||||
used_boxes.append(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
|
# find all other boxes that fit inside the boundary
|
||||||
for compare_index, compare_box in enumerate(boxes):
|
for compare_index, compare_box in enumerate(boxes):
|
||||||
if compare_index in used_boxes:
|
if compare_index in used_boxes:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user