ImFusion C++ SDK 4.4.0
ImFusion::US::EveryFrameModel Class Reference

#include <ImFusion/US/MotionTrajectoryModel.h>

Motion model with independent poses for each frame, exposing only one frame at a time for optimization. More...

Inheritance diagram for ImFusion::US::EveryFrameModel:

Detailed Description

Motion model with independent poses for each frame, exposing only one frame at a time for optimization.

This model maintains a pose (as a transformation matrix) for each frame in the range [0, m_size). Only the parameters of the currently focused frame are accessible.

Coordinate systems for motion can be chosen using CoordinateMode:

  • Global: world coordinate system.
  • ImagePlane: coordinates in the 2D image plane of each frame (X-Y plane).
  • Trajectory: aligned with the motion trajectory, with Z-axis along the direction of travel.

The model uses the averaging interval to define the radius of the sliding window for the estimated trajectory direction. For each frame, an amount equal to m_averageInterval of matrices from the fitted motion is taken before and after the currently estimated frame, and the average motion is calculated for the motion within this interval.

For example, for fitted motion of size 100: For the frame at position i = 20 and m_averageInterval = 5, the average motion in the range [15, 25] will be calculated.

Note
The range of the sliding window does not exceed the bounds of the fitted motion.

Public Types

enum class  CoordinateMode : int { Global = 0 , ImagePlane = 1 , Trajectory = 2 }
 Coordinate system of optimization (only relevant for restricted movement, e.g. in image plane direction). More...
Public Types inherited from ImFusion::US::MotionTrajectoryModel
typedef std::function< MotionTrajectoryModel *(int)> createModelFunc
 Function signature for creating a motion model with a given size.

Public Member Functions

 EveryFrameModel (int size, int focus=0)
std::string name () const override
 Returns the name of the current motion model.
int numberOfParameters () const override
std::vector< double > parameters () const override
void setParameters (const std::vector< double > &pars) override
 Sets pose parameters for the currently focused frame.
std::vector< mat4 > defineMotion () const override
 Defines the motion trajectory across all frames.
mat4 fitMatrices (const std::vector< mat4 > &mat) override
 Fit motion parameters to a sequence of pose matrices.
void setFocus (int f)
int focus () const
void setMatrix (const mat4 &m, int which)
 Sets the parameters of the waypoint with index which from the transformation matrix.
mat4 matrix (int which) const
 Retrieves the transformation matrix for a specified frame.
void setAverageInterval (int ai)
 Sets the number of frames to average for estimating trajectory direction.
int averageInterval () const
 Gets the averaging interval used for trajectory estimation.
void setCoordinateMode (CoordinateMode mode)
CoordinateMode coordinateMode () const
Public Member Functions inherited from ImFusion::US::MotionTrajectoryModel
 MotionTrajectoryModel (int size)
void setRelativeShiftMatrix (const mat4 &relShiftBefore)
 Sets the relative shift matrix applied before the motion.
void configure (const Properties *p) override
 Sets one or multiple properties.
void configuration (Properties *p) const override
 Retrieve the properties of this 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

Protected Attributes

int m_focus
 Current frame the exposed parameters correspond to.
std::vector< mat4 > m_relativeMatrices
 Matrices to set transformation in desired local coordinate system.
std::vector< mat4 > m_originalMatrices
 Original tracking matrices.
CoordinateMode m_coordMode = CoordinateMode::Global
int m_averageInterval = 1
 Averaging interval to average trajectory direction.
Protected Attributes inherited from ImFusion::US::MotionTrajectoryModel
const int m_size
 Size of the model, regularly the number of frames.
std::vector< double > m_pars
 Full motion parameter vector - not necessarily the exposed ones.
mat4 m_relShift
 Generic helper matrix to incorporate optional shifts. Considered by rigidMotion().
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Additional Inherited Members

Static Public Member Functions inherited from ImFusion::US::MotionTrajectoryModel
static std::vector< std::pair< std::string, createModelFunc > > & supportedModels ()
 Returns a list of supported motion models.
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
Protected Member Functions inherited from ImFusion::US::MotionTrajectoryModel
std::vector< mat4 > rigidMotion (const mat4 &m0, const mat4 &m1, int startFrame=0, int endFrame=-1) const
 Helper method to interpolate a rigid motion between m0 and m1.

Member Enumeration Documentation

◆ CoordinateMode

Coordinate system of optimization (only relevant for restricted movement, e.g. in image plane direction).

Enumerator
Global 

Global coordinate system is used for rigid transformation.

ImagePlane 

Coordinate system in local image coordinates (x-y plane = image plane).

Trajectory 

Coordinate system in trajectory system (z-axis = trajectory).

Constructor & Destructor Documentation

◆ EveryFrameModel()

ImFusion::US::EveryFrameModel::EveryFrameModel ( int size,
int focus = 0 )
explicit
Parameters
sizenumber of frames in the motion sequence.
focusindex of currently focused frame

Member Function Documentation

◆ name()

std::string ImFusion::US::EveryFrameModel::name ( ) const
inlineoverridevirtual

Returns the name of the current motion model.

Implements ImFusion::US::MotionTrajectoryModel.

◆ numberOfParameters()

int ImFusion::US::EveryFrameModel::numberOfParameters ( ) const
inlineoverridevirtual

Accessors for the exposed parameters. Default implement access the full vector m_pars, but derived classes may choose to only expose some of them depending on some internal state.

Reimplemented from ImFusion::US::MotionTrajectoryModel.

◆ parameters()

std::vector< double > ImFusion::US::EveryFrameModel::parameters ( ) const
overridevirtual

◆ setParameters()

void ImFusion::US::EveryFrameModel::setParameters ( const std::vector< double > & pars)
overridevirtual

Sets pose parameters for the currently focused frame.

Only 6 elements in the input vector are assumed.

Parameters
pars6-element vector representing the pose parameters (assumed to be a 6D vector: translation + Euler angles).
Warning
If the pars.size() > 6 then the behaviour is undefined.

Reimplemented from ImFusion::US::MotionTrajectoryModel.

◆ defineMotion()

std::vector< mat4 > ImFusion::US::EveryFrameModel::defineMotion ( ) const
overridevirtual

Defines the motion trajectory across all frames.

Computes the transformation matrix for each frame based on the current coordinate mode.

  • If coordinateMode() == Global, the motion for each frame is computed from its pose parameters.
  • If coordinateMode() != Global, the motion must be defined by externally provided matrices using fitMatrices(const std::vector<mat4>&). These populate both the original and relative matrices used in the final motion.

Implements ImFusion::US::MotionTrajectoryModel.

◆ fitMatrices()

mat4 ImFusion::US::EveryFrameModel::fitMatrices ( const std::vector< mat4 > & mat)
overridevirtual

Fit motion parameters to a sequence of pose matrices.

Computes and sets internal parameters to approximate the given trajectory, and returns a registration matrix to align the model to the input poses.

Parameters
matPose waypoints as 4x4 matrices, using the TOWORLD convention.
Returns
Registration matrix aligning the fitted motion to the input.

Implements ImFusion::US::MotionTrajectoryModel.

◆ matrix()

mat4 ImFusion::US::EveryFrameModel::matrix ( int which) const

Retrieves the transformation matrix for a specified frame.

If the index is out of range, returns mat4::Identity().

◆ setAverageInterval()

void ImFusion::US::EveryFrameModel::setAverageInterval ( int ai)

Sets the number of frames to average for estimating trajectory direction.

Parameters
aiAveraging interval (number of frames).

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