Example #1
0
        public Doll EstimateSingleFrame(float w, float h, List <Keypoint> keypoints)
        {
            // Setup unknown variables' information
            var estimationDoll = new Doll();

            double[] unknowns;
            double[] lowerLimits;
            double[] upperLimits;
            InitializeInputArrays(estimationDoll, out unknowns, out lowerLimits, out upperLimits);
            double[] unknowns2 = new double[unknowns.Length];

            // Call Nelder-mead solver in Microsoft.Solver.Foundation librabry
            var solution = NelderMeadSolver.Solve(
                (input) =>
            {
                ReflectDecisionsToDoll(input, estimationDoll);
                estimationDoll.RenewAllPositions();
                return(estimationDoll.CalculateResidualSum(w, h, (float)input[0], keypoints));
            },
                unknowns, lowerLimits, upperLimits);

            Debug.WriteLine($"{solution.Result}");
            Debug.WriteLine($"Solution = {solution.GetSolutionValue(0)}");

            // Output
            return(estimationDoll);
        }