ImFusion SDK 4.3
KeyframeMotionModel Class Reference

#include <ImFusion/US/MotionTrajectoryModel.h>

This model allows users to define a set of keyframes—each associated with a specific frame index. More...

+ Inheritance diagram for KeyframeMotionModel:

Detailed Description

This model allows users to define a set of keyframes—each associated with a specific frame index.

These keyframes are used to interpolate transformation matrices for each integer frame in the range [0, m_size).

  • Keyframe indices (keys) are not restricted to the [0, m_size) range; negative values or values exceeding m_size are allowed.
  • If the smallest keyframe index is greater than 0, all frames from 0 up to that key will be filled using the matrix of the first keyframe.
  • Similarly, if the largest keyframe index is less than m_size - 1, all remaining frames will be filled with the matrix of the last keyframe.
Note
This model does not override setParameters(). Therefore, all parameters in the internal vector (m_pars) are exposed, not just those associated with the current focus frame.
Warning
applyFocus() and defineMotion() assume that the parameter vector contains at least 6 elements. Supplying fewer may result in undefined behavior or runtime errors.

Public Member Functions

 KeyframeMotionModel (int size)
 
std::string name () const override
 Returns the name of the current motion model.
 
std::vector< mat4 > defineMotion () const override
 Computes a set of m_size matrices describing the intended motion trajectory.
 
mat4 fitMatrices (const std::vector< mat4 > &mat) override
 Not Implemented.
 
void setFocus (int f)
 Sets a new focus and sets all the elements of the current parameters to 0.0.
 
int focus () const
 Gets an index of the current focus.
 
void applyFocus ()
 Applies the pose from current parameters to the keyframe at the focus index.
 
void configure (const Properties *p) override
 Loads the current keyframe configuration from properties.
 
void configuration (Properties *p) const override
 Stores the current keyframe configuration into properties.
 
void addKeyframe (int frame, const mat4 &matrix)
 Adds a keyframe at the specified frame index.
 
void removeKeyframe (int frame)
 Removes a keyframe at the specified frame index.
 
bool isKeyframe (int frame) const
 Returns true if a keyframe exists at the given frame.
 
mat4 keyframeMatrix (int frame) const
 Returns the transformation matrix of the specified keyframe.
 
std::vector< int > keyframes () const
 Returns all frame indices that have associated keyframes.
 
- Public Member Functions inherited from 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.
 
virtual int numberOfParameters () const
 
virtual std::vector< double > parameters () const
 
virtual void setParameters (const std::vector< double > &pars)
 
- Public Member Functions inherited from 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
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Protected Attributes

std::map< int, mat4 > m_keyFrames
 Map of frame indices to transformation matrices.
 
int m_focus
 Index of the currently selected (focused) keyframe.
 
- Protected Attributes inherited from 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 Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Additional Inherited Members

- Public Types inherited from MotionTrajectoryModel
typedef std::function< MotionTrajectoryModel *(int)> createModelFunc
 Function signature for creating a motion model with a given size.
 
- Static Public Member Functions inherited from MotionTrajectoryModel
static std::vector< std::pair< std::string, createModelFunc > > & supportedModels ()
 Returns a list of supported motion models.
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 
- Protected Member Functions inherited from 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.
 

Constructor & Destructor Documentation

◆ KeyframeMotionModel()

KeyframeMotionModel ( int size)
explicit
Parameters
sizeThe number of frames in the motion sequence.

Member Function Documentation

◆ name()

std::string name ( ) const
inlineoverridevirtual

Returns the name of the current motion model.

Implements MotionTrajectoryModel.

◆ defineMotion()

std::vector< mat4 > defineMotion ( ) const
overridevirtual

Computes a set of m_size matrices describing the intended motion trajectory.

Implements MotionTrajectoryModel.

◆ fitMatrices()

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

Not Implemented.

Warning
Always returns an identity matrix.
Returns
mat4::Identity()

Implements MotionTrajectoryModel.

◆ applyFocus()

void applyFocus ( )

Applies the pose from current parameters to the keyframe at the focus index.

If a keyframe exists at the current focus, its matrix will be updated using the pose represented by the current parameters (assumed to be a 6D vector: translation + Euler angles).

Warning
If the parameter vector contains fewer than 6 values, the behavior is undefined.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Loads the current keyframe configuration from properties.

Looks for subproperties named "Keyframe", each of which can contain:

  • "frame" (int): The frame index of the keyframe.
  • "matrix" (mat4): The transformation matrix for that keyframe.

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Stores the current keyframe configuration into properties.

Writes subproperties named "Keyframe" for each defined keyframe. Each subproperty contains:

  • "frame" (int): The frame index of the keyframe.
  • "matrix" (mat4): The transformation matrix for that keyframe.

Reimplemented from Configurable.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close