Skip to content

Commit f14bb9b

Browse files
fbogometa-codesync[bot]
authored andcommitted
Add a parameter for regularizer weights. (#861)
Summary: Pull Request resolved: #861 Allow the caller to set a stronger regularization towards the identity/global parameters passed as initialization. Reviewed By: jeongseok-meta Differential Revision: D87931014 fbshipit-source-id: 7d716e31c41b5e50a260b1d3609257931a9c407a
1 parent 21e414f commit f14bb9b

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

momentum/marker_tracking/marker_tracker.cpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -710,23 +710,12 @@ Character addSkinnedLocatorParametersToTransform(Character character) {
710710
return character;
711711
}
712712

713-
/// Calibrate character identity parameters (scaling, locators, blend shapes) from marker data.
714-
///
715-
/// This is the main calibration function that solves for global character parameters
716-
/// that remain constant across all frames. It uses a multi-stage approach:
717-
/// 1. Initialize poses with fixed identity
718-
/// 2. Alternate between solving global parameters and poses
719-
/// 3. Fine-tune locator positions
720-
///
721-
/// @param markerData Marker observations for each frame
722-
/// @param config Calibration configuration settings
723-
/// @param character Character model to calibrate (modified in-place)
724-
/// @param identity Output identity parameters (scaling, blend shapes)
725713
void calibrateModel(
726714
const std::span<const std::vector<Marker>> markerData,
727715
const CalibrationConfig& config,
728716
Character& character,
729-
ModelParameters& identity) {
717+
ModelParameters& identity,
718+
const std::array<float, 3>& regularizerWeights) {
730719
MT_CHECK(
731720
identity.v.size() == character.parameterTransform.numAllModelParameters(),
732721
"Input identity parameters {} do not match character parameters {}",
@@ -809,7 +798,7 @@ void calibrateModel(
809798
motion.topRows(transform.numAllModelParameters()),
810799
trackingConfig,
811800
firstFrame,
812-
0.0,
801+
regularizerWeights.at(0),
813802
config.enforceFloorInFirstFrame,
814803
config.firstFramePoseConstraintSet); // still solving a subset
815804
std::tie(identity.v, character.locators, character.skinnedLocators) =
@@ -842,8 +831,8 @@ void calibrateModel(
842831
motion.topRows(transform.numAllModelParameters()),
843832
trackingConfig,
844833
frameIndices,
845-
0.0,
846-
/*regularizer*/ // allow large change at initialization without any regularization
834+
regularizerWeights.at(0), // note: ideally allow large change at initialization with 0
835+
// or low regularization weight
847836
config.enforceFloorInFirstFrame,
848837
config.firstFramePoseConstraintSet);
849838
} else {
@@ -859,7 +848,8 @@ void calibrateModel(
859848
calibBodySet, // only solve for identity and not markers
860849
motion.topRows(transform.numAllModelParameters()),
861850
trackingConfig,
862-
0.0 /*regularizer*/, // allow large change at initialization without any regularization
851+
regularizerWeights.at(0), // note: ideally allow large change at initialization with 0
852+
// or low regularization weight
863853
frameStride,
864854
config.enforceFloorInFirstFrame,
865855
config.firstFramePoseConstraintSet);
@@ -878,7 +868,8 @@ void calibrateModel(
878868
motion,
879869
trackingConfig,
880870
frameIndices,
881-
0.0, // TODO: use a small regularization to prevent too large a change
871+
regularizerWeights.at(
872+
1), // note: ideally use a small regularization to prevent too large a change
882873
config.enforceFloorInFirstFrame,
883874
config.firstFramePoseConstraintSet); // still solving a subset
884875
} else {
@@ -888,7 +879,8 @@ void calibrateModel(
888879
locatorSet | calibBodySetExtended,
889880
motion,
890881
trackingConfig,
891-
0.0, // TODO: use a small regularization to prevent too large a change
882+
regularizerWeights.at(
883+
1), // note: ideally use a small regularization to prevent too large a change
892884
frameStride,
893885
config.enforceFloorInFirstFrame,
894886
config.firstFramePoseConstraintSet); // still solving a subset
@@ -922,7 +914,6 @@ void calibrateModel(
922914
// Finally, fine tune marker offsets with fix identity.
923915
MT_LOGI_IF(config.debug, "Fine-tune marker offsets");
924916

925-
// TODO: use a larger regularizer to prevent too large a change.
926917
if (config.greedySampling > 0) {
927918
motion = trackSequence(
928919
markerData,
@@ -931,7 +922,8 @@ void calibrateModel(
931922
motion,
932923
trackingConfig,
933924
frameIndices,
934-
0.0,
925+
regularizerWeights.at(
926+
2), // note: ideally use a higher regularizer weight to prevent too large a change
935927
config.enforceFloorInFirstFrame,
936928
config.firstFramePoseConstraintSet);
937929
} else {
@@ -941,7 +933,8 @@ void calibrateModel(
941933
locatorSet,
942934
motion,
943935
trackingConfig,
944-
0.0,
936+
regularizerWeights.at(
937+
2), // note: ideally use a higher regularizer weight to prevent too large a change
945938
frameStride,
946939
config.enforceFloorInFirstFrame,
947940
config.firstFramePoseConstraintSet);

momentum/marker_tracking/marker_tracker.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,17 @@ Eigen::MatrixXf trackPosesForFrames(
175175
/// updated in return.
176176
/// @param[in,out] identity Initial identity parameters that get updated in return. It could also
177177
/// hold the pose of the first frame for better initialization for tracking later.
178+
/// @param[in] regularizerWeights Regularizer weights used for global parameters, at each different
179+
/// stage (3 in total) of the calibration. Ideally these weights would increase over stages: in
180+
/// stage 0, 0 or low regularization weight to allow a large change; in stage 1, a small
181+
/// regularization weight to prevent too large of a change; in stage 2, a higher regularization
182+
/// weight to prevent large changes.
178183
void calibrateModel(
179184
std::span<const std::vector<momentum::Marker>> markerData,
180185
const CalibrationConfig& config,
181186
momentum::Character& character,
182-
momentum::ModelParameters& identity);
187+
momentum::ModelParameters& identity,
188+
const std::array<float, 3>& regularizerWeights = {0.0f, 0.0f, 0.0f});
183189

184190
/// Calibrate locator offsets of a character from input identity and marker data.
185191
///

0 commit comments

Comments
 (0)