Exemple #1
0
        public static MoCapBodyFrame Average(params MoCapBodyFrame[] values)
        {
            if (values == null || values.Length == 0)
            {
                throw new Exception("Empty values list!");
            }

            var transforms = new TransformTime[(int)MoCapKinectBone.Count][];

            for (var i = 0; i < (int)MoCapKinectBone.Count; i++)
            {
                transforms[i] = new TransformTime[values.Length];

                for (var j = 0; j < values.Length; j++)
                {
                    transforms[i][j] = values[j].SkeletonTransforms[i];
                }
            }

            var ret = new MoCapBodyFrame
            {
                SkeletonTransforms = new TransformTime[(int)MoCapKinectBone.Count]
            };

            for (var i = 0; i < (int)MoCapKinectBone.Count; i++)
            {
                ret.SkeletonTransforms[i] = TransformTime.Average(transforms[i]);
            }
            return(ret);
        }
Exemple #2
0
        public static MoCapFaceFrame Average(params MoCapFaceFrame[] values)
        {
            if (values == null || values.Length == 0)
            {
                throw new Exception("Empty values list!");
            }

            var transforms = new TransformTime[values.Length];

            for (var i = 0; i < values.Length; i++)
            {
                transforms[i] = values[i].FaceTransform;
            }

            var weights = new float[(int)MoCapKinectFacialExpression.Count][];

            for (var i = 0; i < (int)MoCapKinectFacialExpression.Count; i++)
            {
                weights[i] = new float[values.Length];

                for (var j = 0; j < values.Length; j++)
                {
                    weights[i][j] = values[j].ExpressionWeights[i];
                }
            }

            var ret = new MoCapFaceFrame
            {
                ExpressionWeights = new float[(int)MoCapKinectFacialExpression.Count]
            };

            ret.FaceTransform = TransformTime.Average(transforms);

            for (var i = 0; i < (int)MoCapKinectFacialExpression.Count; i++)
            {
                ret.ExpressionWeights[i] = MathHelper.Average(weights[i]);
            }

            return(ret);
        }