@@ -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)
725713void 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 );
0 commit comments