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

Error function that projects 3D skeleton points through a bone-parented camera using an IntrinsicsModelT<T> and penalizes reprojection error in pixel space. More...

#include <camera_projection_error_function.h>

Inheritance diagram for momentum::CameraProjectionErrorFunctionT< T >:

Public Member Functions

 CameraProjectionErrorFunctionT (const Skeleton &skel, 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())
 CameraProjectionErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt, const CameraT< T > &camera, size_t cameraParent=kInvalidIndex)
 Convenience constructor that extracts intrinsics and extrinsics from a Camera.
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 ProjectionConstraintT< T > &constraint)
void clearConstraints ()
void setConstraints (std::vector< ProjectionConstraintT< T > > constraints)
const std::vector< ProjectionConstraintT< T > > & getConstraints () const
size_t getNumConstraints () const
bool empty () const
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
virtual const Character * getCharacter () const
 For mesh-based error functions, get access to the underlying character.
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)
virtual bool needsMesh () const

Protected Attributes

std::vector< ProjectionConstraintT< 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_
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::CameraProjectionErrorFunctionT< T >

Error function that projects 3D skeleton points through a bone-parented camera using an IntrinsicsModelT<T> and penalizes reprojection error in pixel space.

If camera parameters are fixed and off-screen robustness is needed, consider using ProjectionErrorFunctionT with matrices from <momentum/camera/projection_utils.h> instead.

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 (cameraOffset is used directly as eyeFromWorld).

Each constraint specifies a 3D point attached to a joint and a target 2D pixel. The error is the squared distance between the projected point and the target.

Definition at line 46 of file camera_projection_error_function.h.

Constructor & Destructor Documentation

◆ CameraProjectionErrorFunctionT() [1/2]

template<typename T>
momentum::CameraProjectionErrorFunctionT< T >::CameraProjectionErrorFunctionT ( const Skeleton & skel,
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() )

◆ CameraProjectionErrorFunctionT() [2/2]

template<typename T>
momentum::CameraProjectionErrorFunctionT< T >::CameraProjectionErrorFunctionT ( const Skeleton & skel,
const ParameterTransform & pt,
const CameraT< T > & camera,
size_t cameraParent = kInvalidIndex )

Member Function Documentation

◆ addConstraint()

template<typename T>
void momentum::CameraProjectionErrorFunctionT< T >::addConstraint ( const ProjectionConstraintT< T > & constraint)

Definition at line 53 of file camera_projection_error_function.cpp.

References constraints_.

◆ clearConstraints()

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

Definition at line 83 of file camera_projection_error_function.h.

◆ empty()

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

Definition at line 99 of file camera_projection_error_function.h.

◆ getConstraints()

template<typename T>
const std::vector< ProjectionConstraintT< T > > & momentum::CameraProjectionErrorFunctionT< T >::getConstraints ( ) const
inlinenodiscard

Definition at line 91 of file camera_projection_error_function.h.

◆ getError()

◆ getGradient()

◆ getJacobian()

template<typename T>
double momentum::CameraProjectionErrorFunctionT< 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::CameraProjectionErrorFunctionT< T >::getJacobianSize ( ) const
nodiscardfinalvirtual

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 303 of file camera_projection_error_function.cpp.

References constraints_.

◆ getNumConstraints()

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

Definition at line 95 of file camera_projection_error_function.h.

◆ setConstraints()

template<typename T>
void momentum::CameraProjectionErrorFunctionT< T >::setConstraints ( std::vector< ProjectionConstraintT< T > > constraints)
inline

Definition at line 87 of file camera_projection_error_function.h.

Member Data Documentation

◆ cameraOffset_

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

◆ cameraParent_

template<typename T>
size_t momentum::CameraProjectionErrorFunctionT< T >::cameraParent_
protected

◆ constraints_

template<typename T>
std::vector<ProjectionConstraintT<T> > momentum::CameraProjectionErrorFunctionT< T >::constraints_
protected

◆ intrinsicsMapping_

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

Definition at line 106 of file camera_projection_error_function.h.

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

◆ intrinsicsModel_

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

◆ skeletonDerivative_


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