SAM3DetectHandle Struct
Default implementation using SAM3Detect. More...
Declaration
Included Headers
Base struct
| struct | InferenceHandle |
|
Interface for SAM3 segmentation inference. More... | |
Public Member Functions Index
| tl::expected< void, std::string > | load (const std::filesystem::path &bundle_manifest, std::string_view runtime_id) override |
|
Load a runtime variant from a SAM3 model bundle. More... | |
| tl::expected< moveit_pro_ml::SAM3DetectResult, std::string > | predict (const moveit_pro_ml::data::Tensor< float, moveit_pro_ml::data::format::NCHW > &image, std::string_view text_prompt, const std::vector< moveit_pro_ml::SAM3Box > &box_prompts, float confidence_threshold=0.5f) const override |
|
Run SAM3 prediction with text and box prompts. More... | |
| void | requestTerminate () const override |
|
Request termination of any in-flight predict() call. More... | |
| void | clearTerminate () const override |
|
Clear a previously-set terminate flag. More... | |
| std::optional< moveit_pro_ml::Device > | servingDevice () const override |
|
The device actually serving inference, if known. More... | |
Public Member Attributes Index
| std::shared_ptr< moveit_pro_ml::SAM3Detect > | model |
| moveit_pro_ml::model::RunControl | control |
Description
Default implementation using SAM3Detect.
Definition at line 251 of file get_masks_2d_from_exemplar.hpp.
Public Member Functions
clearTerminate()
| virtual |
Clear a previously-set terminate flag.
Must be called before predict() if the previous predict() was halted, otherwise the next run aborts immediately. The behavior calls this at the start of doWork() before signalling that halt is allowed via notifyCanHalt().
Declaration at line 263 of file get_masks_2d_from_exemplar.hpp, definition at line 571 of file get_masks_2d_from_exemplar.cpp.
load()
| virtual |
Load a runtime variant from a SAM3 model bundle.
Idempotent: called from every doWork(), and once a model is loaded every later call returns immediately. The model therefore latches for the handle's lifetime — the arguments are read on the first call only.
That means this is not the place a changed bundle or runtime is detected. The caller compares the ports against what it latched and fails the Behavior, because swapping models mid-run would mean a multi-second uninterruptible load at an arbitrary point in an Objective.
A failed load leaves the handle empty, so the next call retries rather than reporting a model that was never built.
- 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.
Declaration at line 253 of file get_masks_2d_from_exemplar.hpp, definition at line 531 of file get_masks_2d_from_exemplar.cpp.
predict()
| virtual |
Run SAM3 prediction with text and box prompts.
- Parameters
-
image Input image to segment in NCHW format [1, 3, 1008, 1008] (RGB float normalized to [-1,1])
text_prompt Text description for segmentation (can be empty)
box_prompts Bounding box prompts in normalized CXCYWH format
confidence_threshold Minimum confidence score to keep a mask (default 0.5)
- Returns
Expected containing masks and scores, or error message
Declaration at line 257 of file get_masks_2d_from_exemplar.hpp, definition at line 549 of file get_masks_2d_from_exemplar.cpp.
requestTerminate()
| virtual |
Request termination of any in-flight predict() call.
Thread-safe; intended to be called from the behavior's doHalt() handler while another thread is blocked inside predict(). The terminate flag is sticky; the caller is responsible for calling clearTerminate() before the next predict() so a stale flag does not abort it.
Declaration at line 261 of file get_masks_2d_from_exemplar.hpp, definition at line 566 of file get_masks_2d_from_exemplar.cpp.
servingDevice()
| virtual |
The device actually serving inference, if known.
Defaults to unknown so test doubles need not implement it. The behavior uses this to surface an operator-facing warning when inference silently fell back to CPU.
Declaration at line 265 of file get_masks_2d_from_exemplar.hpp, definition at line 579 of file get_masks_2d_from_exemplar.cpp.
Public Member Attributes
control
| mutable |
Definition at line 268 of file get_masks_2d_from_exemplar.hpp.
model
|
Definition at line 267 of file get_masks_2d_from_exemplar.hpp.
The documentation for this struct was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.