44 double getError(
const Eigen::VectorX<T>& parameters)
final;
46 double getGradient(
const Eigen::VectorX<T>& parameters, Eigen::VectorX<T>& gradient)
final;
53 const Eigen::VectorX<T>& parameters,
55 Eigen::Ref<Eigen::MatrixX<T>> jacobianBlock,
56 Eigen::Ref<Eigen::VectorX<T>> residualBlock,
57 size_t& actualRows)
override;
60 void updateParameters(Eigen::VectorX<T>& parameters,
const Eigen::VectorX<T>& gradient)
final;
64 return universalParameters_;
69 return needsMeshPerFrame_;
74 return needsMeshSequence_;
87 return frameParameters_.size();
91 return frameParameters_[frame];
95 return frameParameters_;
99 return perFrameParameterIndices_;
103 return universalParameterIndices_;
125 return ¶meterTransform_;
129 return perFrameErrorFunctions_.at(iFrame);
133 return perFrameErrorFunctions_;
137 return sequenceErrorFunctions_.at(iFrame);
141 return sequenceErrorFunctions_;
145 void setFrameParametersFromJoinedParameterVector(
const Eigen::VectorX<T>& parameters);
149 getPerFrameJacobian(Eigen::MatrixX<T>& jacobian, Eigen::VectorX<T>& residual,
size_t& position);
152 double getSequenceErrorFunctionsJacobian(
153 Eigen::MatrixX<T>& jacobian,
154 Eigen::VectorX<T>& residual,
162 std::vector<ModelParametersT<T>> frameParameters_;
165 void updateParameterSets(
const ParameterSet& activeParams);
168 std::vector<Eigen::Index> perFrameParameterIndices_;
171 std::vector<Eigen::Index> universalParameterIndices_;
175 std::vector<std::vector<std::shared_ptr<SkeletonErrorFunctionT<T>>>> perFrameErrorFunctions_;
176 std::vector<std::vector<std::shared_ptr<SequenceErrorFunctionT<T>>>> sequenceErrorFunctions_;
181 std::atomic<size_t> numTotalPerFrameErrorFunctions_ = 0;
182 std::atomic<size_t> numTotalSequenceErrorFunctions_ = 0;
185 std::atomic<bool> needsMeshPerFrame_{
false};
187 std::atomic<bool> needsMeshSequence_{
false};
A dense column-major matrix whose underlying storage capacity grows monotonically and is reused acros...
Sequence solver based on banded normal equations and banded factorization.
const std::vector< Eigen::Index > & getUniversalParameterIndices() const
double computeJacobianBlock(const Eigen::VectorX< T > ¶meters, size_t blockIndex, Eigen::Ref< Eigen::MatrixX< T > > jacobianBlock, Eigen::Ref< Eigen::VectorX< T > > residualBlock, size_t &actualRows) override
double getGradient(const Eigen::VectorX< T > ¶meters, Eigen::VectorX< T > &gradient) final
const ModelParametersT< T > & getFrameParameters(size_t frame) const
const std::vector< Eigen::Index > & getPerFrameParameterIndices() const
const std::vector< ModelParametersT< T > > & getFrameParameters() const
void finalizeJacobianComputation() override
Optional cleanup after all Jacobian blocks have been computed.
const auto & getErrorFunctions(size_t iFrame) const
void setJoinedParameterVector(const Eigen::VectorX< T > &joinedParameters)
size_t getJacobianBlockCount() const override
Returns the number of Jacobian blocks available.
bool needsMeshSequence() const
Returns whether the sequence error functions need the mesh.
Eigen::VectorX< T > getJoinedParameterVectorFromFrameParameters(std::span< const ModelParametersT< T > > frameParameters) const
Returns a joined parameter vector from a span of frame parameters.
SequenceSolverFunctionT(const SequenceSolverFunctionT &)=delete
const auto & getErrorFunctions() const
SequenceSolverFunctionT(SequenceSolverFunctionT &&)=delete
size_t getNumFrames() const
const Skeleton * getSkeleton() const
void setEnabledParameters(const ParameterSet ¶meterSet) final
Specifies which parameters should be optimized.
const ParameterTransformT< T > * getParameterTransform() const
const auto & getSequenceErrorFunctions() const
ModelParametersT< T > getUniversalParameters() const
size_t getJacobianBlockSize(size_t blockIndex) const override
Returns the maximum number of rows for a specific Jacobian block.
void setFrameParameters(size_t frame, const ModelParametersT< T > ¶meters)
Eigen::VectorX< T > getJoinedParameterVector() const
const Character & getCharacter() const
SequenceSolverFunctionT & operator=(SequenceSolverFunctionT &&)=delete
const ParameterSet & getUniversalParameterSet() const
void addSequenceErrorFunction(size_t startFrame, std::shared_ptr< SequenceErrorFunctionT< T > > errorFunction)
~SequenceSolverFunctionT() override
SequenceSolverFunctionT(const Character &character, const ParameterTransformT< T > ¶meterTransform, const ParameterSet &universal, size_t nFrames)
void initializeJacobianComputation(const Eigen::VectorX< T > ¶meters) override
bool needsMeshPerFrame() const
Returns whether the per-frame error functions need the mesh.
void updateParameters(Eigen::VectorX< T > ¶meters, const Eigen::VectorX< T > &gradient) final
SequenceSolverFunctionT & operator=(const SequenceSolverFunctionT &)=delete
const auto & getSequenceErrorFunctions(size_t iFrame) const
double getError(const Eigen::VectorX< T > ¶meters) final
void addErrorFunction(size_t frame, std::shared_ptr< SkeletonErrorFunctionT< T > > errorFunction)
Abstract base class for optimization objective functions.
SkeletonT< float > Skeleton
constexpr size_t kAllFrames
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
std::bitset< kMaxModelParams > ParameterSet
Bitset for model parameter enablement.
A character model with skeletal structure, mesh, and optional components.
Represents the complete state of a model's mesh.
A vector of size numModelParams holding the values of all model parameters for a character.
MeshStateT< T > meshState
SkeletonStateT< T > skeletonState
Represents the complete state of a skeleton.