Make stationary detection more resilient to inaccurate boxes (#10597)

This commit is contained in:
Nicolas Mowen
2024-03-21 16:44:26 -06:00
committed by GitHub
parent e5595ebb2f
commit df6c3b14dd
2 changed files with 40 additions and 7 deletions

View File

@@ -339,6 +339,12 @@ def average_boxes(boxes: list[list[int, int, int, int]]) -> list[int, int, int,
return [np.mean(x_mins), np.mean(y_mins), np.mean(x_max), np.mean(y_max)]
def median_of_boxes(boxes: list[list[int, int, int, int]]) -> list[int, int, int, int]:
"""Return a box that is the median of a list of boxes."""
sorted_boxes = sorted(boxes, key=lambda x: area(x))
return sorted_boxes[int(len(sorted_boxes) / 2.0)]
def intersects_any(box_a, boxes):
for box in boxes:
if box_overlaps(box_a, box):