Detector

drone.detector

Copyright MIT GNU General Public License v3.0

MIT BWSI Autonomous Drone Racing Course - UAV Neo

File Name: detector.py File Description: Defines the interface of the Detector module of the drone_core library.

class detector.Detection(class_id: str, score: float, bbox: tuple)

Represents a single object detection result.

class_id

The label or numeric ID of the detected object.

score

Confidence score between 0.0 and 1.0.

bbox

Bounding box as (center_x, center_y, width, height) in pixels.

class detector.Detector

Provides access to onboard ML object detection via the Coral EdgeTPU.

abstractmethod get_detections() List[Detection]

Returns the latest list of object detections from the EdgeTPU.

Returns:

A list of Detection objects, each containing a class_id, score, and bounding box in pixel coordinates. Empty list if no detections or the EdgeTPU node is not running.

Example:

detections = uav.detector.get_detections()
for det in detections:
    print(f"Found {det.class_id} at ({det.bbox[0]}, {det.bbox[1]})")
abstractmethod get_detections_async() List[Detection]

Returns the latest detections without the drone in “go” mode.

Warning

This function breaks the start-update paradigm and should only be used in Jupyter Notebook.