ImFusion C++ SDK 4.5.0
ImFusion::US::FrameGrabbingPresets Class Reference

#include <ImFusion/US/FrameGrabbingPresets.h>

Named ultrasound frame-grabbing presets: image templates, frame geometries, and imaging depths. More...

Inheritance diagram for ImFusion::US::FrameGrabbingPresets:

Detailed Description

Named ultrasound frame-grabbing presets: image templates, frame geometries, and imaging depths.

Each preset pairs an ImageTemplate (for recognizing a probe or on-screen layout in incoming frames) with a US::FrameGeometry and a depth in millimeters. Live frame grabbing and ProcessedUltrasoundStream use match() to pick the best preset for the current frame and then apply geometry() and depth() to ProcessUltrasound processing.

Presets can be stored in an IMF file via toSis(), save(), and load(), using FrameGrabbingConfigComponent on the SharedImageSet. The ROI defines a screen region (for example a depth readout) shared by all templates.

See also
FrameGrabbingAlgorithm
FrameGrabbingConfigComponent
ProcessedUltrasoundStream

Classes

struct  ROI
 Pixel rectangle on the frame, used as the depth-readout region for ImageTemplate matching. More...
struct  Preset
 One named preset: display name, imaging depth, and frame geometry in pixels. More...

Public Member Functions

bool operator== (const FrameGrabbingPresets &other) const
int match (const MemImage *memImg, double threshold=0.0)
 Finds the preset whose ImageTemplate best matches the given frame using the L1 similarity metric: d(x, y) = |x - y|.
const US::FrameGeometrygeometry (int index=-1) const
 Returns the frame geometry for the given preset index, or for the current preset when index is -1.
double depth (int index=-1) const
 Returns the imaging depth in millimeters for the given preset index, or for the current preset when index is -1.
std::string name (int index=-1) const
 Returns the preset name for the given index, or for the current preset when index is -1.
int size () const
 Number of stored presets.
double estimateDepth (const US::FrameGeometry *newGeometry) const
 Estimates imaging depth in millimeters for a newly detected frame geometry.
int addPreset (Preset &&preset)
 Appends a preset without an image template (template must be added separately for match() to use it).
int addTemplate (std::unique_ptr< ImageTemplate > &&templ, Preset &&preset)
 Appends an ImageTemplate and a preset at the same index.
int addTemplate (std::unique_ptr< ImageTemplate > &&templ, std::unique_ptr< US::FrameGeometry > &&geom, double depth)
 Appends a template and a preset built from geometry and depth (name is generated as "Depth Xmm").
void setPreset (int index, std::unique_ptr< US::FrameGeometry > &&geom, double depth)
 Updates geometry, depth, and name ("Depth Xmm") of an existing preset. Emits signalPresetChanged.
void clear ()
 Removes all presets and templates. Emits signalPresetsRemoved for the cleared range.
std::vector< std::stringpresetNames () const
 Returns the names of all presets in order.
void setCurrentPreset (int presetIndex)
 Sets the active preset by index. Emits signalCurrentPresetChanged when the index changes.
bool setCurrentPreset (const std::string &presetName)
 Sets the active preset by name.
bool removePreset (int presetIndex, bool silent=false)
 Removes the preset and matching template at presetIndex.
bool removePreset (const std::string &presetName, bool silent=false)
 Removes the preset with the given name.
const PresetcurrentPreset () const
 Returns the currently active preset. Valid only when currentPresetIndex() >= 0.
int currentPresetIndex () const
 Index of the active preset, or -1 if none is selected.
std::unique_ptr< FrameGrabbingPresets > clone () const
 Deep copy of all presets, templates, and settings.
std::unique_ptr< SharedImageSettoSis () const
 Builds a SharedImageSet with template images and FrameGrabbingConfigComponent holding preset properties and ROI.
bool save (const std::string &path) const
 Saves presets to an IMF file (ZSTD compression).
void load (const SharedImageSet *sis)
 Loads presets from a SharedImageSet that contains FrameGrabbingConfigComponent and template images.
void load (const std::string &path)
 Loads presets from an IMF file path.
ROI roi () const
 Depth-readout ROI taken from the first template region, or empty if there are no templates.
void setRoi (const ROI &roi)
 Updates the depth-readout region on all templates.
void setSpeedOfSound (double speed, bool adjust=true)
 Sets speed of sound in m/s. When adjust is true, scales all preset depths proportionally.
double speedOfSound () const
 Speed of sound in m/s used when converting or adjusting depths (default 1540).
void configure (const Properties *p) override
 Configure this object instance by de-serializing the given Properties.
void configuration (Properties *p) const override
 Serialize the current object configuration into the given Properties object.
Public Member Functions inherited from ImFusion::Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 Configurable (const Configurable &rhs)
 Configurable (Configurable &&rhs) noexcept
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept

Public Attributes

Signal signalPresetsLoaded
 Emitted after load() finishes rebuilding presets and templates.
Signal< int > signalPresetCreated
 Emitted with the index of a preset added via addPreset or addTemplate.
Signal< int > signalPresetChanged
 Emitted when a preset name, depth, or geometry changes.
Signal< int, int > signalPresetsRemoved
 Emitted when one or more presets are removed. The signal arguments describe the range [start, end) of removed preset indices.
Signal< int > signalCurrentPresetChanged
 Emitted when the active preset index changes.
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.

Additional Inherited Members

Protected Member Functions inherited from ImFusion::Utils::NotCopyable
 NotCopyable (NotCopyable &&) noexcept=default
NotCopyable & operator= (NotCopyable &&) noexcept=default
 NotCopyable (const NotCopyable &)=delete
NotCopyable & operator= (const NotCopyable &)=delete
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Member Function Documentation

◆ match()

int ImFusion::US::FrameGrabbingPresets::match ( const MemImage * memImg,
double threshold = 0.0 )

Finds the preset whose ImageTemplate best matches the given frame using the L1 similarity metric: d(x, y) = |x - y|.

Checks the current preset first for a perfect match, then scans all templates. Uses m_matchingThreshold when threshold is zero, otherwise threshold is the minimum score required.

Returns
Preset index, or -1 if no template exceeds the threshold.

◆ geometry()

const US::FrameGeometry * ImFusion::US::FrameGrabbingPresets::geometry ( int index = -1) const

Returns the frame geometry for the given preset index, or for the current preset when index is -1.

Returns
nullptr if the index is invalid or no current preset is set.

◆ depth()

double ImFusion::US::FrameGrabbingPresets::depth ( int index = -1) const

Returns the imaging depth in millimeters for the given preset index, or for the current preset when index is -1.

Returns
-1.0 if the index is invalid or no current preset is set.

◆ name()

std::string ImFusion::US::FrameGrabbingPresets::name ( int index = -1) const

Returns the preset name for the given index, or for the current preset when index is -1.

Returns
An empty string if the index is invalid or no current preset is set.

◆ estimateDepth()

double ImFusion::US::FrameGrabbingPresets::estimateDepth ( const US::FrameGeometry * newGeometry) const

Estimates imaging depth in millimeters for a newly detected frame geometry.

Uses a reference preset (second-to-last when several exist, otherwise the only one) whose depth and geometry are known, and scales that depth by how the fan size changed in pixels (linear width or sector/convex radius ratios). Used by FrameGrabbingAlgorithm when auto-adding or updating presets. If newGeometry is null, returns reference depth + 10 mm. Result is rounded to 1 mm (< 80) or 5 mm (≥ 80).

◆ addPreset()

int ImFusion::US::FrameGrabbingPresets::addPreset ( Preset && preset)

Appends a preset without an image template (template must be added separately for match() to use it).

Returns
Index of the new preset. Emits signalPresetCreated.

◆ addTemplate()

int ImFusion::US::FrameGrabbingPresets::addTemplate ( std::unique_ptr< ImageTemplate > && templ,
Preset && preset )

Appends an ImageTemplate and a preset at the same index.

Returns
Index of the new preset.

◆ setCurrentPreset()

bool ImFusion::US::FrameGrabbingPresets::setCurrentPreset ( const std::string & presetName)

Sets the active preset by name.

Returns
False if no preset with that name exists.

◆ removePreset()

bool ImFusion::US::FrameGrabbingPresets::removePreset ( int presetIndex,
bool silent = false )

Removes the preset and matching template at presetIndex.

Returns
False if the index is out of range. Emits signalPresetsRemoved unless silent is true.

◆ configure()

void ImFusion::US::FrameGrabbingPresets::configure ( const Properties * p)
overridevirtual

Configure this object instance by de-serializing the given Properties.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configuration() for the inverse functionality

Reimplemented from ImFusion::Configurable.

◆ configuration()

void ImFusion::US::FrameGrabbingPresets::configuration ( Properties * p) const
overridevirtual

Serialize the current object configuration into the given Properties object.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configure() for the inverse functionality

Reimplemented from ImFusion::Configurable.


The documentation for this class was generated from the following file:
  • ImFusion/US/FrameGrabbingPresets.h
Search Tab / S to search, Esc to close