Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
Loading...
Searching...
No Matches
auterion::ObjectDetectionProvider Class Reference

Publisher for 2D object detections. More...

#include <auterion_sdk/object_detection/object_detection_provider.hpp>

Public Member Functions

 ObjectDetectionProvider (SDK &sdk, DetectionProviderOptions options={})
 Construct a new Object Detection Provider object.
 
virtual ~ObjectDetectionProvider ()
 Destroy the Object Detection Provider object.
 
 ObjectDetectionProvider (const ObjectDetectionProvider &)=delete
 
ObjectDetectionProvideroperator= (const ObjectDetectionProvider &)=delete
 
 ObjectDetectionProvider (ObjectDetectionProvider &&)=delete
 
ObjectDetectionProvideroperator= (ObjectDetectionProvider &&)=delete
 
void updateDetections2D (const ImageDetections2D &image_detections)
 Publishes 2D object detections.
 
void setClassCatalog (const ClassCatalog &catalog)
 Replaces the class catalog at runtime, for example after a model switch.
 
ObjectDetectionEnabledSubscriptionobjectDetectionEnabledSubscription () const
 Get the object detection enabled subscription.
 
ObjectDetectionProvidersubscribeObjectDetectionEnabled (ObjectDetectionEnabledCallback callback=nullptr)
 Subscribe to object detection enabled state changes to control provider operation.
 

Detailed Description

Publisher for 2D object detections.

Example usage:

To publish 2D object detections:

auterion::ObjectDetectionProvider object_detection_provider{
auterion::ClassCatalog::fromModelOrder({"person", "vehicle"}))};
// Create detections from an input image. detectionsForImage(), in
// <auterion_sdk/object_detection/detections_from_image.hpp>, fills in the frame fields.
auto detections = auterion::detectionsForImage(image);
// Add a detection
detection.bbox.center = Eigen::Vector2d{100.0, 200.0};
detection.bbox.size_x = 50.0;
detection.bbox.size_y = 30.0;
detection.object_hypotheses.push_back({"person", 0.95});
detections.detections.push_back(std::move(detection));
// Publish the detections
object_detection_provider.updateDetections2D(detections);
static ClassCatalog fromModelOrder(const std::vector< std::string > &names_in_model_order)
Names in model index order: element i names class i.
Publisher for 2D object detections.
Definition object_detection_provider.hpp:230
SDK execution class. All callbacks are called on the same thread.
Definition auterion.hpp:119
Eigen::Vector2d center
Center of the bounding box in pixels.
Definition detection_2d.hpp:45
double size_y
Height of the bounding box in pixels.
Definition detection_2d.hpp:47
double size_x
Width of the bounding box in pixels.
Definition detection_2d.hpp:46
Represents a single 2D object detection.
Definition detection_2d.hpp:61
BoundingBox2D bbox
The 2D bounding box of the detected object.
Definition detection_2d.hpp:62
std::vector< ObjectHypothesis > object_hypotheses
A list of hypotheses for the object in the bounding box.
Definition detection_2d.hpp:64
Configures an ObjectDetectionProvider: where detections go, and their class names.
Definition object_detection_provider.hpp:119
DetectionProviderOptions & withClassCatalog(ClassCatalog catalog)
Set the class catalog the ground station shows.
Definition object_detection_provider.hpp:156

To control provider operation based on object detection enabled state:

auterion::ObjectDetectionProvider object_detection_provider{sdk};
// Subscribe to object detection enabled state changes and control processing accordingly
object_detection_provider.subscribeObjectDetectionEnabled([&](bool enabled) {
if (enabled) {
std::cout << "Service enabled - starting processing pipeline" << std::endl;
// Start heavy computational work: inference, image processing, etc.
startImageProcessing();
} else {
std::cout << "Service disabled - stopping processing pipeline" << std::endl;
// Stop heavy computational work to save system resources
stopImageProcessing();
}
});

To check object detection enabled state programmatically and control processing:

auterion::ObjectDetectionProvider object_detection_provider{sdk};
// Activate subscription to object detection enabled state
object_detection_provider.subscribeObjectDetectionEnabled();
// Later, check state and control processing accordingly (e.g. in a loop)
if (object_detection_provider.objectDetectionEnabledSubscription().isLastValid()) {
bool enabled = object_detection_provider.objectDetectionEnabledSubscription().last();
if (enabled) {
// Object detection is active - ensure processing is running
ensureProcessingIsActive();
} else {
// Object detection is inactive - stop unnecessary work
stopProcessingToSaveResources();
}
}

Constructor & Destructor Documentation

◆ ObjectDetectionProvider()

auterion::ObjectDetectionProvider::ObjectDetectionProvider ( SDK sdk,
DetectionProviderOptions  options = {} 
)
explicit

Construct a new Object Detection Provider object.

Parameters
sdkThe SDK instance to use for creating providers.
optionsWhere detections go, and the class names to publish with them. Defaults to both channels enabled and no class names.

Member Function Documentation

◆ objectDetectionEnabledSubscription()

ObjectDetectionEnabledSubscription & auterion::ObjectDetectionProvider::objectDetectionEnabledSubscription ( ) const

Get the object detection enabled subscription.

Returns
Reference to the object detection enabled subscription.

◆ setClassCatalog()

void auterion::ObjectDetectionProvider::setClassCatalog ( const ClassCatalog catalog)

Replaces the class catalog at runtime, for example after a model switch.

No-op when MAVLink output is disabled. Thread-safe with respect to updateDetections2D.

Parameters
catalogThe catalog backing the class ids.

◆ subscribeObjectDetectionEnabled()

ObjectDetectionProvider & auterion::ObjectDetectionProvider::subscribeObjectDetectionEnabled ( ObjectDetectionEnabledCallback  callback = nullptr)
inline

Subscribe to object detection enabled state changes to control provider operation.

Providers should use this to start/stop computational work based on whether the object detection is enabled or disabled, avoiding unnecessary resource usage.

Parameters
callbackThe callback function to be invoked when the object detection enabled state changes. Should implement logic to start/stop processing accordingly.
Returns
Reference to this object for method chaining.

◆ updateDetections2D()

void auterion::ObjectDetectionProvider::updateDetections2D ( const ImageDetections2D image_detections)

Publishes 2D object detections.

Parameters
image_detectionsThe image detections to publish.

The documentation for this class was generated from the following file: