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, const std::string &detections_topic="object_detection/detections_2d", const std::string &enabled_topic="object_detection/detections_2d_enabled")
 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.
 
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{sdk};
// Create detections from an input image
// The timestamp must match the input image that was used to generate these detections
detections.image_timestamp = input_image_timestamp; // e.g. from camera timestamp
// 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.emplace_back({"person", 0.95});
detections.detections.push_back(std::move(detection));
// Publish the detections
object_detection_provider.updateDetections2D(detections);
Publisher for 2D object detections.
Definition object_detection_provider.hpp:177
SDK execution class. All callbacks are called on the same thread.
Definition auterion.hpp:97
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
Contains 2D detections for a specific image.
Definition image_detections_2d.hpp:44
rclcpp::Time image_timestamp
Timestamp of the image.
Definition image_detections_2d.hpp:45
std::vector< Detection2D > detections
List of 2D detections in the image.
Definition image_detections_2d.hpp:46

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,
const std::string &  detections_topic = "object_detection/detections_2d",
const std::string &  enabled_topic = "object_detection/detections_2d_enabled" 
)

Construct a new Object Detection Provider object.

Parameters
sdkThe SDK instance to use for creating providers.
detections_topicTopic name for publishing 2D detections.
enabled_topicTopic name for subscribing to detection enabled state.

Member Function Documentation

◆ objectDetectionEnabledSubscription()

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

Get the object detection enabled subscription.

Returns
Reference to the object detection enabled subscription.

◆ 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: