plot
Signature:
Detection.plot(
image: PIL.Image.Image | str | numpy.ndarray,
results: list[DetectionResult],
as_image: bool = True,
) -> Image | numpy.ndarray
Description:
Draw detection boxes and class labels on the image.
Parameters:
Parameter | Type | Default | Description |
|---|---|---|---|
|
| Required | Original input image, image file path, or NumPy array. |
|
| Required | Detection results returned by |
|
|
| Whether to return |
Returns:
Image | numpy.ndarray
Image: Returned whenas_image=True, see "Sensor and State Data / Image".numpy.ndarray: Returned whenas_image=False.
Raises:
TypeError: image type not supported.
ValueError: Image file read 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)
image_with_boxes = detector.plot(image.to_numpy(), results, as_image=True)
image_with_boxes.save("detections.png")