public void Update(UnifiedSkeleton skel, int groundTruthFrameIndex)
        {
            // Update the result of the specified range
            int startFrameIndex = Math.Max(groundTruthFrameIndex - PostCompareFrames, 0);
            int endFrameIndex   = Math.Min(groundTruthFrameIndex + PreCompareFrames, this.groundTruthFrames.Count - 1);

            for (int index = startFrameIndex; index <= endFrameIndex; index++)
            {
                // Compare the frame with the current new frame and update the result
                double comparedResult = UnifiedSkeleton.ComputeDistance(this.groundTruthFrames[index], skel);
                if (this.result[index] > comparedResult)
                {
                    this.score        += (Scoring.GetScore(comparedResult) - Scoring.GetScore(this.result[index]));
                    this.result[index] = comparedResult;
                }
            }
        }
Ejemplo n.º 2
0
        public static double ComputeDistance(UnifiedSkeleton groundTruth, UnifiedSkeleton skel)
        {
            if (groundTruth == null || skel == null || !groundTruth.IsValid || groundTruth.Bones.Count == 0 || !skel.IsValid)
            {
                return(DistanceForInvalidBone);
            }

            double discrepancy           = 0.0;
            double normalizedDenominator = 0.0;

            foreach (var item in groundTruth.bones)
            {
                if (!item.Value.IsValid)
                {
                    // throw new Exception("It shouldn't have invalid data in ground truth skeleton!");
                    continue;
                }

                double weight = DefaultWeight;
                if (groundTruth.Weights.ContainsKey(item.Key))
                {
                    weight = groundTruth.Weights[item.Key];
                }
                normalizedDenominator += weight;

                double distance = DistanceForInvalidBone;
                if (skel.Bones.ContainsKey(item.Key) && skel.Bones[item.Key].IsValid)
                {
                    distance = Vector3D.Distance(item.Value.NormalizedBone, skel.Bones[item.Key].NormalizedBone);
                }
                discrepancy += distance * weight;
            }

            // Normalize the discrepancy to [0, 2]
            return(normalizedDenominator != 0.0 ? discrepancy / normalizedDenominator : DistanceForInvalidBone);
        }