Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
tracker_utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
16
17namespace momentum {
18
19std::vector<std::vector<momentum::PositionData>> createConstraintData(
20 std::span<const std::vector<momentum::Marker>> markerData,
21 const momentum::LocatorList& locators);
22
23std::vector<std::vector<momentum::SkinnedLocatorConstraint>> createSkinnedConstraintData(
24 std::span<const std::vector<momentum::Marker>> markerData,
25 const momentum::SkinnedLocatorList& locators);
26
27// TODO: remove the one in momentum
28
29// Create a LocatorCharacter where each locator is a bone in its skeleton. This character is used
30// for calibrating locator offsets (as bone offset parameters).
32 const momentum::Character& sourceCharacter,
33 const std::string& prefix);
34
49 const momentum::Character& sourceCharacter,
50 float maxDistance = 3.0f,
51 float minSkinWeight = 0.03f,
52 bool verbose = false,
53 float markerDiameter = 0.0f);
54
63
64std::vector<momentum::SkinnedLocatorTriangleConstraintT<float>> createSkinnedLocatorMeshConstraints(
65 const momentum::Character& character,
66 float cutoffWeight = 0.05f,
67 float maxSearchDistanceCm = 3.0f,
68 float maxNormalAngleDeg = 30.0f);
69
74std::vector<std::vector<size_t>> buildTriangleAdjacency(const momentum::Mesh& mesh);
75
93std::vector<momentum::CandidateTriangle> findCandidateTrianglesDfs(
94 const momentum::Mesh& mesh,
95 const momentum::SkinWeights& skin,
96 const momentum::Skeleton& skeleton,
97 std::span<const std::vector<size_t>> adjacency,
98 size_t startTriangleIdx,
99 const Eigen::Vector3f& initialPoint,
100 const Eigen::Vector3f& referenceNormal,
101 uint32_t parentJointIdx,
102 float maxSearchDistanceCm,
103 float maxNormalAngleDeg = 30.0f);
104
105// Extract locator offsets from a LocatorCharacter for a normal Character given input calibrated
106// parameters
108 const momentum::Character& locatorCharacter,
109 const momentum::CharacterParameters& calibParams);
110
125std::vector<std::vector<momentum::PlaneDataT<float>>> computeFloorContactConstraints(
126 const momentum::Character& character,
127 const Eigen::MatrixXf& motion,
128 const std::vector<momentum::PlaneDataT<float>>& floorConstraints,
129 const std::vector<size_t>& frameIndices,
130 float percentile);
131
132// TODO: move to momentum proper
134 const momentum::ModelParameters& params,
135 const momentum::ParameterSet& parameterSet);
136
137std::tuple<Eigen::VectorXf, momentum::LocatorList, momentum::SkinnedLocatorList>
139 const momentum::ModelParameters& param,
140 const momentum::Character& sourceCharacter,
141 const momentum::Character& targetCharacter);
142
144 const momentum::ModelParameters& param,
145 const momentum::Character& sourceCharacter);
146
147void fillIdentity(
148 const momentum::ParameterSet& idSet,
149 const momentum::ModelParameters& identity,
150 Eigen::MatrixXf& motion);
151
152// convert from joint to model parameters using only the parameters active in idSet
154 const Character& c,
155 const ParameterSet& idSet,
156 const JointParameters& jointIdentity);
157
158void removeIdentity(
159 const momentum::ParameterSet& idSet,
160 const momentum::ModelParameters& identity,
161 Eigen::MatrixXf& motion);
162
163std::vector<std::vector<momentum::Marker>> extractMarkersFromMotion(
164 const momentum::Character& character,
165 const Eigen::MatrixXf& motion);
166
169std::vector<std::pair<std::string, float>> computeSkinnedLocatorMeshDistances(
170 const momentum::Character& character);
171
172} // namespace momentum
SkeletonT< float > Skeleton
Definition fwd.h:263
LocatorList extractLocatorsFromCharacter(const Character &locatorCharacter, const CharacterParameters &calibParams)
std::vector< CandidateTriangle > findCandidateTrianglesDfs(const Mesh &mesh, const SkinWeights &skin, const Skeleton &skeleton, std::span< const std::vector< size_t > > adjacency, size_t startTriangleIdx, const Eigen::Vector3f &initialPoint, const Eigen::Vector3f &referenceNormal, uint32_t parentJointIdx, float maxSearchDistanceCm, float maxNormalAngleDeg)
Find candidate triangles by walking along the mesh surface using DFS.
Mesh extractBlendShapeFromParams(const momentum::ModelParameters &param, const momentum::Character &sourceCharacter)
std::tuple< Eigen::VectorXf, LocatorList, SkinnedLocatorList > extractIdAndLocatorsFromParams(const ModelParameters &param, const Character &sourceCharacter, const Character &targetCharacter)
momentum::Character locatorsToSkinnedLocators(const momentum::Character &sourceCharacter, float maxDistance, float minSkinWeight, bool verbose, float markerDiameter)
Convert locators to skinned locators by finding the closest point on the mesh surface that matches th...
MeshT< float > Mesh
Definition fwd.h:20
std::vector< std::vector< size_t > > buildTriangleAdjacency(const Mesh &mesh)
Build triangle adjacency: for each triangle, find triangles that share an edge.
std::vector< std::vector< SkinnedLocatorConstraint > > createSkinnedConstraintData(const std::span< const std::vector< Marker > > markerData, const SkinnedLocatorList &locators)
std::vector< std::pair< std::string, float > > computeSkinnedLocatorMeshDistances(const Character &character)
Compute the distance from each skinned locator to the closest point on the mesh surface.
void fillIdentity(const ParameterSet &idSet, const ModelParameters &identity, Eigen::MatrixXf &motionNoId)
Character createLocatorCharacter(const Character &sourceCharacter, const std::string &prefix)
void removeIdentity(const ParameterSet &idSet, const ModelParameters &identity, Eigen::MatrixXf &motionWithId)
std::vector< momentum::SkinnedLocatorTriangleConstraintT< float > > createSkinnedLocatorMeshConstraints(const momentum::Character &character, float cutoffWeight, float maxSearchDistanceCm, float maxNormalAngleDeg)
std::vector< SkinnedLocator > SkinnedLocatorList
A collection of locators attached to a skeleton.
JointParametersT< float > JointParameters
Definition types.h:135
ModelParameters jointIdentityToModelIdentity(const Character &c, const ParameterSet &idSet, const JointParameters &jointIdentity)
momentum::Character skinnedLocatorsToLocators(const momentum::Character &sourceCharacter)
Convert skinned locators to regular locators by selecting the bone with the highest skin weight.
CharacterParametersT< float > CharacterParameters
Definition types.h:168
std::vector< std::vector< PositionData > > createConstraintData(const std::span< const std::vector< Marker > > markerData, const LocatorList &locators)
ModelParameters extractParameters(const ModelParameters &params, const ParameterSet &parameterSet)
ModelParametersT< float > ModelParameters
Definition types.h:105
std::vector< std::vector< PlaneDataT< float > > > computeFloorContactConstraints(const Character &character, const MatrixXf &motion, const std::vector< PlaneDataT< float > > &floorConstraints, const std::vector< size_t > &frameIndices, float percentile)
std::bitset< kMaxModelParams > ParameterSet
Bitset for model parameter enablement.
Definition types.h:430
std::vector< std::vector< Marker > > extractMarkersFromMotion(const Character &character, const Eigen::MatrixXf &motion)
std::vector< Locator > LocatorList
A collection of locators attached to a skeleton.
Definition locator.h:79
A character model with skeletal structure, mesh, and optional components.
Definition character.h:32
Point-on-plane or Point-in-half-plane constraint data.
Linear blend skinning weights for a character mesh: per-vertex joint indices and influence weights.