Skip to main content

InferenceHandle Struct

Interface for SAM2 point-prompted segmentation inference. More...

Declaration

struct moveit_pro::behaviors::GetMasks2DFromPointQuery::InferenceHandle { ... }

Included Headers

#include <sam2_segmentation.hpp>

Derived Structs

structSAM2SegmentHandle

Default implementation using SAM2Segment over the shared model pool. More...

Public Destructor Index

~InferenceHandle ()=default

Public Member Functions Index

tl::expected< void, std::string >load (const std::filesystem::path &bundle_manifest, std::string_view runtime_id)=0

Load a runtime variant from a SAM2 segment model bundle. More...

tl::expected< moveit_pro_ml::SAM2SegmentResult, std::string >predict (const moveit_pro_ml::data::Tensor< float, moveit_pro_ml::data::format::NHWC > &image, const std::vector< moveit_pro_ml::data::Point > &point_prompts) const =0

Run SAM2 point-prompted segmentation. More...

voidrequestTerminate () const =0

Request termination of any in-flight predict() call. More...

voidclearTerminate () const =0

Clear a previously-set terminate flag. More...

std::optional< moveit_pro_ml::Device >servingDevice () const

The device actually serving inference, if known. More...

Description

Interface for SAM2 point-prompted segmentation inference.

Allows dependency injection of different SAM2 implementations for testing with GoogleMock.

Definition at line 46 of file sam2_segmentation.hpp.

Public Destructor

~InferenceHandle()

virtual moveit_pro::behaviors::GetMasks2DFromPointQuery::InferenceHandle::~InferenceHandle ()
virtual default

Definition at line 48 of file sam2_segmentation.hpp.

Public Member Functions

clearTerminate()

virtual void moveit_pro::behaviors::GetMasks2DFromPointQuery::InferenceHandle::clearTerminate ()

Clear a previously-set terminate flag.

Definition at line 82 of file sam2_segmentation.hpp.

load()

virtual tl::expected< void, std::string > moveit_pro::behaviors::GetMasks2DFromPointQuery::InferenceHandle::load (const std::filesystem::path & bundle_manifest, std::string_view runtime_id)

Load a runtime variant from a SAM2 segment model bundle.

Idempotent — if a model is already loaded, returns immediately without reloading. The Behavior, not the handle, rejects a bundle or runtime change after the first load.

Parameters
bundle_manifest

Path to the relocatable versioned bundle manifest.

runtime_id

Runtime variant to select from the bundle.

Returns

An error message if model initialization fails.

Definition at line 60 of file sam2_segmentation.hpp.

predict()

virtual tl::expected< moveit_pro_ml::SAM2SegmentResult, std::string > moveit_pro::behaviors::GetMasks2DFromPointQuery::InferenceHandle::predict (const moveit_pro_ml::data::Tensor< float, moveit_pro_ml::data::format::NHWC > & image, const std::vector< moveit_pro_ml::data::Point > & point_prompts)

Run SAM2 point-prompted segmentation.

Parameters
image

Input image in NHWC format [1, H, W, 3] (RGB float normalized to [0, 1]).

point_prompts

Point prompts to segment against.

Returns

Expected containing the segmentation mask, or error message.

Definition at line 71 of file sam2_segmentation.hpp.

requestTerminate()

virtual void moveit_pro::behaviors::GetMasks2DFromPointQuery::InferenceHandle::requestTerminate ()

Request termination of any in-flight predict() call.

Definition at line 77 of file sam2_segmentation.hpp.

servingDevice()

virtual std::optional< moveit_pro_ml::Device > moveit_pro::behaviors::GetMasks2DFromPointQuery::InferenceHandle::servingDevice ()
inline virtual

The device actually serving inference, if known.

Definition at line 87 of file sam2_segmentation.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.