Skip to main content

detect

Signature:

Detection.detect(
image: PIL.Image.Image | str | numpy.ndarray,
confidence: float = 0.5,
iou_threshold: float = 0.45,
**kwargs: Any,
) -> list[DetectionResult]

Description:

Perform object detection.

Parameters:

Parameter

Type

Default

Description

image

PIL.Image.Image | str | numpy.ndarray

Required

Input image, image file path, or NumPy array.

confidence

float

0.5

Confidence threshold.

iou_threshold

float

0.45

NMS IoU threshold.

**kwargs

Any

-

Additional parameters passed to the underlying inference backend.

Returns:

list[DetectionResult], see "Sensor and State Data / DetectionResult"

Raises:

TypeError: image type not supported.

ValueError: Image file read failed, or invalid inference parameters.

RuntimeError: Inference engine internal execution failed.

Example:

from boosteros.brain import Detection
from boosteros.robots.booster import BoosterRobot

robot = BoosterRobot()
detector = Detection(model="soccer")

image = robot.get_image(img_type="rgb")
results = detector.detect(image.to_numpy(), confidence=0.4)
print(results)
# Example output: [DetectionResult(class_name='Ball', class_id=0, confidence=0.794202983379364, ...), ...]