Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 1bc3259

Browse files
committed
remove largest area and nearest to center
1 parent 2e93ec1 commit 1bc3259

File tree

1 file changed

+3
-42
lines changed

1 file changed

+3
-42
lines changed

modules/auto_landing/auto_landing.py

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ class DetectionSelectionStrategy(Enum):
1616
Strategies for selecting which detection to use when multiple targets are detected.
1717
"""
1818

19-
NEAREST_TO_CENTER = "nearest_to_center" # Choose detection closest to image center
20-
LARGEST_AREA = "largest_area" # Choose detection with largest bounding box area
21-
HIGHEST_CONFIDENCE = "highest_confidence" # Choose detection with highest confidence
2219
FIRST_DETECTION = "first_detection" # Use first detection in list (original behavior)
20+
HIGHEST_CONFIDENCE = "highest_confidence" # Choose detection with highest confidence
2321

2422

2523
class AutoLandingInformation:
@@ -57,7 +55,7 @@ def create(
5755
im_h: float,
5856
im_w: float,
5957
local_logger: logger.Logger,
60-
selection_strategy: DetectionSelectionStrategy = DetectionSelectionStrategy.NEAREST_TO_CENTER,
58+
selection_strategy: DetectionSelectionStrategy = DetectionSelectionStrategy.FIRST_DETECTION,
6159
) -> "tuple [bool, AutoLanding | None ]":
6260
"""
6361
fov_x: The horizontal camera field of view in degrees.
@@ -104,46 +102,9 @@ def _select_detection(self, detections: list) -> int | None:
104102
if not detections:
105103
return None
106104

107-
if len(detections) == 1:
105+
if len(detections) == 1 or self.__selection_strategy == DetectionSelectionStrategy.FIRST_DETECTION:
108106
return 0
109107

110-
if self.__selection_strategy == DetectionSelectionStrategy.FIRST_DETECTION:
111-
return 0
112-
113-
if self.__selection_strategy == DetectionSelectionStrategy.NEAREST_TO_CENTER:
114-
# Find detection closest to image center
115-
image_center_x = self.im_w / 2
116-
image_center_y = self.im_h / 2
117-
118-
min_distance = float("inf")
119-
selected_index = 0
120-
121-
for i, detection in enumerate(detections):
122-
det_center_x, det_center_y = detection.get_centre()
123-
distance = math.sqrt(
124-
(det_center_x - image_center_x) ** 2 + (det_center_y - image_center_y) ** 2
125-
)
126-
if distance < min_distance:
127-
min_distance = distance
128-
selected_index = i
129-
130-
return selected_index
131-
132-
if self.__selection_strategy == DetectionSelectionStrategy.LARGEST_AREA:
133-
# Find detection with largest bounding box area
134-
max_area = 0
135-
selected_index = 0
136-
137-
for i, detection in enumerate(detections):
138-
width = detection.x_2 - detection.x_1
139-
height = detection.y_2 - detection.y_1
140-
area = width * height
141-
if area > max_area:
142-
max_area = area
143-
selected_index = i
144-
145-
return selected_index
146-
147108
if self.__selection_strategy == DetectionSelectionStrategy.HIGHEST_CONFIDENCE:
148109
# Find detection with highest confidence
149110
max_confidence = 0

0 commit comments

Comments
 (0)