ImFusion SDK 4.3
ImFusion::Pose Namespace Reference

Conversion of pose matrices. More...

Detailed Description

Conversion of pose matrices.

Set of more advanced function on poses.

Enumerations

enum  TransformationConvention { FROMWORLD = 0 , TOWORLD = 1 }
 Convention of matrix transformations. More...
 

Functions

mat4 eulerToMat (const vec3 &trans, const vec3 &rot)
 Convert a translation and Euler angles to a homogeneous transformation matrix. Angles are in degrees.
 
mat3 eulerToMat (const vec3 &rot)
 Convert Euler angles to a rotation matrix. Angles are in degrees.
 
mat4 eulerToMat (const double *pose)
 Convenience method using input from a double pointer with at least 6 values. Angles are in degrees.
 
void matToEuler (const mat4 &M, vec3 &transOut, vec3 &rotOut)
 Convert a homogeneous transformation matrix to translation and Euler angles. Angles are in degrees.
 
vec3 matToEuler (const mat3 &M)
 Convert a rotation matrix to Euler angles. Angles are in degrees.
 
void matToEuler (const mat4 &M, double *poseOut)
 Convenience method converting matrix into a double pointer. Angles are in degrees.
 
mat4 eulerDerivative (int paramIndex, const double *params)
 Compute the derivative of a Euler matrix with respect to a parameter (between 0 and 5)
 
void eulerMatToLog (const mat4 &M, vec3 &transLog, vec3 &rotLog)
 Compute the logarithm a Euler matrix on the Lie algebra.
 
mat4 logToEulerMat (const vec3 &transLog, const vec3 &rotLog)
 Compute the exponential of an element on the Lie algebra of Euler matrices.
 
mat4 affineToMat (const vec3 &trans, const vec3 &rot, const vec3 &scale, const vec3 &shear, bool linearScale=false)
 Compose a homogenous transformation matrix from affine parameters.
 
mat4 affineToMat (const double *pose, bool linearScale=false)
 Convenience method using input from a double pointer with at least 12 values.
 
mat4 affineDerivative (int paramIndex, const double *params, bool linearScale=false)
 Compute the derivative of an affine matrix with respect to a parameter (between 0 and 11) The 12 pose parameters are translation(3), rotation(3), scale(3), shear(3)
 
void matToAffine (const mat4 &M, vec3 &transOut, vec3 &rotOut, vec3 &scaleOut, vec3 &shearOut, bool linearScale=false)
 Decompose a homogenous transformation matrix into affine parameters.
 
mat4 scaleMat (const vec3 &scale, bool linearScale=false)
 Return a non-uniform scaling matrix based on logarithmic input parameters.
 
mat4 shearMat (const vec3 &shear)
 Return a matrix with sheared values in the upper right.
 
std::string matToString (const mat4 &pose, bool inDegrees=true)
 Return a one line string that contains the pose rotation in the form of AngleAxis and its translation.
 
std::string matToStringEuler (const mat4 &pose, bool inDegrees=true)
 Return a one line string that contains the pose rotation in the form of euler angles and its translation.
 
Eigen::Quaterniond computeQuaternionAverage (const std::vector< Eigen::Quaterniond > &quats)
 Computes the average rotation of the provided quaternions quats.
 
Eigen::Quaterniond computeQuaternionWeightedAverage (const std::vector< Eigen::Quaterniond > &quats, const std::vector< double > &weights)
 Computes the weighted average rotation of the provided quaternions quats with non-negative weights weights.
 
template<typename It>
mat4 computeAveragePose (It begin, It end, std::function< mat4(It &)> functor=([](It &it) { return *it;}))
 Return the average pose of the matrices iterated from begin to end.
 
mat4 computeAveragePose (const std::vector< mat4 > &matrices)
 Return the average pose of the matrices in vector matrices.
 
double geodesicDistance (const isom3 &pose1, const isom3 &pose2)
 Return the geodesic distance between two poses in the manifold SE(3), following Esposito et al. 2019, eq. (5) (doi: 10.1109/TMI.2019.2898480)
 
mat4 interpolate (TransformationConvention tConv, const mat4 &M1, const mat4 &M2, double t, double tr=-1.0)
 Interpolate between two euclidean transformations.
 
mat4 interpolateAxisAngle (const mat4 &M1, const mat4 &M2, double t)
 Interpolate between two euclidean transformations.
 
std::vector< mat4 > distributeMotion (const std::vector< mat4 > &matrices, const mat4 &motion)
 Distribute a rigid motion in equal steps onto a chain of transformations.
 
std::vector< mat4 > distributeMotion2 (const std::vector< mat4 > &matrices, const mat4 &motion)
 Distribute a rigid motion in equal steps onto a chain of transformations.
 
void smooth (const std::vector< mat4 > &M, std::vector< mat4 > &Ms, int windowSize=2)
 Smooth poses by averaging over window.
 
void smoothKalman (const std::vector< mat4 > &measurement, std::vector< mat4 > &prediction, const vec2 &modelSigma=vec2::Ones(), const std::vector< vec2 > &measurementSigma=std::vector< vec2 >())
 Smooth poses using Kalman filter.
 
void distance (const mat4 &M1, const mat4 &M2, double &tOut, double &rOut, double *allOut=0, bool absoluteTrans=false)
 Return distance in translation and rotation of two rigid matrices.
 
mat4 registerPointClouds (const std::vector< vec3 > &ptCloud1, const std::vector< vec3 > &ptCloud2, double *outError=nullptr, bool includeScaling=false, int nbIterations=1000)
 Register two point clouds with a global transformation using RANSAC and ICP (requires PCL)
 
void save (const char *filename, const std::vector< mat4 > &matrices, bool rigidPars=false)
 Save matrices or its rigid pose parameters to a text file.
 
mat4 demeanMatrices (const std::vector< mat4 > &mat, std::vector< mat4 > &demeanedMat)
 Helper function to remove subtract a mean registration of a set of matrices.
 

Enumeration Type Documentation

◆ TransformationConvention

Convention of matrix transformations.

Enumerator
FROMWORLD 

Transformation matrix maps from the world coordinate system to the data one, i.e.

\(x_{data} = matrix * < x_{world}\). Default for images.

TOWORLD 

Transformation matrix maps from the data coordinate system to the world one, i.e.

\(x_{world} = matrix * < x_{data}\). Default for everything but images.

Function Documentation

◆ affineToMat()

mat4 affineToMat ( const double * pose,
bool linearScale = false )

Convenience method using input from a double pointer with at least 12 values.

The 12 pose parameters are translation(3), rotation(3), scale(3), shear(3)

◆ computeAveragePose()

template<typename It>
mat4 computeAveragePose ( It begin,
It end,
std::function< mat4(It &)> functor = ([](It& it) { return *it; }) )

Return the average pose of the matrices iterated from begin to end.

Iterators must be random access iterators. The functor can be used to map differently from iterator to matrix.

◆ interpolate()

mat4 interpolate ( TransformationConvention tConv,
const mat4 & M1,
const mat4 & M2,
double t,
double tr = -1.0 )

Interpolate between two euclidean transformations.

The rotations are interpolated using quaternion slerp. If the optional parameter tr >= 0, t is used as separate weight for translation, tr for rotation and affine parameters. If tConv is set to FROMWORLD, the interpolation will be perform in the inverse space, i.e. M1 and M2 are inverted, interpolated, the result is inverted again and then returned.

◆ interpolateAxisAngle()

mat4 interpolateAxisAngle ( const mat4 & M1,
const mat4 & M2,
double t )

Interpolate between two euclidean transformations.

Only works with rigid poses. For affine poses, use Pose::interpolate(). The rotations are interpolated using Axis-Angle representation.

◆ distributeMotion2()

std::vector< mat4 > distributeMotion2 ( const std::vector< mat4 > & matrices,
const mat4 & motion )

Distribute a rigid motion in equal steps onto a chain of transformations.

Parameters
matriceslist of matrices. Each matrix is the relative transformation to the previous matrix.
motionrelative change of the motion

◆ smoothKalman()

void smoothKalman ( const std::vector< mat4 > & measurement,
std::vector< mat4 > & prediction,
const vec2 & modelSigma = vec2::Ones(),
const std::vector< vec2 > & measurementSigma = std::vector< vec2 >() )

Smooth poses using Kalman filter.

modelSigma gives the sigma of the process noise for the quaternions and the translation. measurementSigma gives the sigma of the measurement noise for the quaternions and the translation.

◆ distance()

void distance ( const mat4 & M1,
const mat4 & M2,
double & tOut,
double & rOut,
double * allOut = 0,
bool absoluteTrans = false )

Return distance in translation and rotation of two rigid matrices.

If the optional parameter allOut is specified, it has to point to space for siz values where the absolute value of individual translation and rotation differences are stored.

Search Tab / S to search, Esc to close