Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::CameraVertexProjectionErrorFunctionT< T > Class Template Reference

Error function that projects skinned mesh vertices through a bone-parented camera using an IntrinsicsModelT<T> and penalizes reprojection error. More...

#include <camera_vertex_projection_error_function.h>

Inheritance diagram for momentum::CameraVertexProjectionErrorFunctionT< T >:

Public Member Functions

 CameraVertexProjectionErrorFunctionT (const Character &character, const ParameterTransform &pt, std::shared_ptr< const IntrinsicsModelT< T > > intrinsicsModel, size_t cameraParent, const Eigen::Transform< T, 3, Eigen::Affine > &cameraOffset=Eigen::Transform< T, 3, Eigen::Affine >::Identity())
 CameraVertexProjectionErrorFunctionT (const Character &character, const ParameterTransform &pt, const CameraT< T > &camera, size_t cameraParent=kInvalidIndex)
 Convenience constructor that extracts intrinsics and extrinsics from a Camera.
const Character * getCharacter () const final
 For mesh-based error functions, get access to the underlying character.
bool needsMesh () const final
double getError (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
double getGradient (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) final
double getJacobian (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) final
size_t getJacobianSize () const final
void addConstraint (const CameraVertexProjectionDataT< T > &constraint)
void clearConstraints ()
void setConstraints (std::vector< CameraVertexProjectionDataT< T > > constraints)
const std::vector< CameraVertexProjectionDataT< T > > & getConstraints () const
size_t getNumConstraints () const
bool empty () const
void setMaxThreads (size_t maxThreads)
Public Member Functions inherited from momentum::SkeletonErrorFunctionT< T >
 SkeletonErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
virtual ~SkeletonErrorFunctionT ()=default
const Skeleton & getSkeleton () const
const ParameterTransform & getParameterTransform () const
void setWeight (T w)
T getWeight () const
void setActiveJoints (const VectorX< bool > &aj)
void setEnabledParameters (const ParameterSet &ps)
virtual void getHessian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >)
virtual double getSolverDerivatives (const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, const size_t actualParameters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad)

Protected Attributes

const Character & character_
std::vector< CameraVertexProjectionDataT< T > > constraints_
std::shared_ptr< const IntrinsicsModelT< T > > intrinsicsModel_
std::optional< CameraIntrinsicsMapping< T > > intrinsicsMapping_
size_t cameraParent_
Eigen::Transform< T, 3, Eigen::Affine > cameraOffset_
SkeletonDerivativeT< T > skeletonDerivative_
size_t maxThreads_ = 0
Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T >
const Skeleton & skeleton_
const ParameterTransform & parameterTransform_
T weight_
VectorX< bool > activeJointParams_
ParameterSet enabledParameters_
bool useHessian_ {false}

Detailed Description

template<typename T>
class momentum::CameraVertexProjectionErrorFunctionT< T >

Error function that projects skinned mesh vertices through a bone-parented camera using an IntrinsicsModelT<T> and penalizes reprojection error.

Combines vertex-based skinning derivatives (with blend shape support) and camera bone extrinsics optimization with optional intrinsics optimization. This enables dense mesh keypoints to contribute to camera parameter optimization, unlike VertexProjectionErrorFunctionT which uses a fixed pre-baked projection matrix.

The camera is rigidly attached to a skeleton joint (cameraParent) with a fixed offset (cameraOffset). If cameraParent is kInvalidIndex, the camera is static in world space.

Definition at line 46 of file camera_vertex_projection_error_function.h.

Constructor & Destructor Documentation

◆ CameraVertexProjectionErrorFunctionT() [1/2]

template<typename T>
momentum::CameraVertexProjectionErrorFunctionT< T >::CameraVertexProjectionErrorFunctionT ( const Character & character,
const ParameterTransform & pt,
std::shared_ptr< const IntrinsicsModelT< T > > intrinsicsModel,
size_t cameraParent,
const Eigen::Transform< T, 3, Eigen::Affine > & cameraOffset = Eigen::Transform<T, 3, Eigen::Affine>::Identity() )

◆ CameraVertexProjectionErrorFunctionT() [2/2]

template<typename T>
momentum::CameraVertexProjectionErrorFunctionT< T >::CameraVertexProjectionErrorFunctionT ( const Character & character,
const ParameterTransform & pt,
const CameraT< T > & camera,
size_t cameraParent = kInvalidIndex )

Member Function Documentation

◆ addConstraint()

template<typename T>
void momentum::CameraVertexProjectionErrorFunctionT< T >::addConstraint ( const CameraVertexProjectionDataT< T > & constraint)

Definition at line 77 of file camera_vertex_projection_error_function.cpp.

References constraints_.

◆ clearConstraints()

template<typename T>
void momentum::CameraVertexProjectionErrorFunctionT< T >::clearConstraints ( )
inline

Definition at line 86 of file camera_vertex_projection_error_function.h.

◆ empty()

template<typename T>
bool momentum::CameraVertexProjectionErrorFunctionT< T >::empty ( ) const
inlinenodiscard

Definition at line 102 of file camera_vertex_projection_error_function.h.

◆ getCharacter()

template<typename T>
const Character * momentum::CameraVertexProjectionErrorFunctionT< T >::getCharacter ( ) const
nodiscardfinalvirtual

For mesh-based error functions, get access to the underlying character.

Error functions that depend only on the skeleton can return nullptr.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 67 of file camera_vertex_projection_error_function.cpp.

References character_.

◆ getConstraints()

template<typename T>
const std::vector< CameraVertexProjectionDataT< T > > & momentum::CameraVertexProjectionErrorFunctionT< T >::getConstraints ( ) const
inlinenodiscard

Definition at line 94 of file camera_vertex_projection_error_function.h.

◆ getError()

◆ getGradient()

◆ getJacobian()

template<typename T>
double momentum::CameraVertexProjectionErrorFunctionT< T >::getJacobian ( const ModelParametersT< T > & params,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState,
Eigen::Ref< Eigen::MatrixX< T > > jacobian,
Eigen::Ref< Eigen::VectorX< T > > residual,
int & usedRows )
finalvirtual

◆ getJacobianSize()

template<typename T>
size_t momentum::CameraVertexProjectionErrorFunctionT< T >::getJacobianSize ( ) const
nodiscardfinalvirtual

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 364 of file camera_vertex_projection_error_function.cpp.

References constraints_, and getJacobianSize().

Referenced by getJacobianSize().

◆ getNumConstraints()

template<typename T>
size_t momentum::CameraVertexProjectionErrorFunctionT< T >::getNumConstraints ( ) const
inlinenodiscard

Definition at line 98 of file camera_vertex_projection_error_function.h.

◆ needsMesh()

template<typename T>
bool momentum::CameraVertexProjectionErrorFunctionT< T >::needsMesh ( ) const
nodiscardfinalvirtual

◆ setConstraints()

template<typename T>
void momentum::CameraVertexProjectionErrorFunctionT< T >::setConstraints ( std::vector< CameraVertexProjectionDataT< T > > constraints)
inline

Definition at line 90 of file camera_vertex_projection_error_function.h.

◆ setMaxThreads()

template<typename T>
void momentum::CameraVertexProjectionErrorFunctionT< T >::setMaxThreads ( size_t maxThreads)
inline

Definition at line 106 of file camera_vertex_projection_error_function.h.

Member Data Documentation

◆ cameraOffset_

template<typename T>
Eigen::Transform<T, 3, Eigen::Affine> momentum::CameraVertexProjectionErrorFunctionT< T >::cameraOffset_
protected

◆ cameraParent_

◆ character_

◆ constraints_

template<typename T>
std::vector<CameraVertexProjectionDataT<T> > momentum::CameraVertexProjectionErrorFunctionT< T >::constraints_
protected

◆ intrinsicsMapping_

template<typename T>
std::optional<CameraIntrinsicsMapping<T> > momentum::CameraVertexProjectionErrorFunctionT< T >::intrinsicsMapping_
protected

Definition at line 114 of file camera_vertex_projection_error_function.h.

Referenced by getError(), getGradient(), and getJacobian().

◆ intrinsicsModel_

template<typename T>
std::shared_ptr<const IntrinsicsModelT<T> > momentum::CameraVertexProjectionErrorFunctionT< T >::intrinsicsModel_
protected

◆ maxThreads_

template<typename T>
size_t momentum::CameraVertexProjectionErrorFunctionT< T >::maxThreads_ = 0
protected

Definition at line 118 of file camera_vertex_projection_error_function.h.

Referenced by getGradient(), and getJacobian().

◆ skeletonDerivative_


The documentation for this class was generated from the following files: