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; }
public static void Average(ref MoCapData data, int smoothingFactor) { if (data.BodyFrames == null || data.BodyFrames.Length == 0 || data.FaceFrames == null || data.FaceFrames.Length == 0) throw new Exception("Invalid data!"); if (smoothingFactor <= 0 || smoothingFactor > data.BodyFrames.Length || smoothingFactor > data.FaceFrames.Length) throw new Exception("Invalid smoothing factor value!"); var bodyFrames = new MoCapBodyFrame[data.BodyFrames.Length/smoothingFactor]; var tempBodyFrames = new MoCapBodyFrame[smoothingFactor]; for (var i = 0; i < data.BodyFrames.Length/smoothingFactor; i++) { for (var j = 0; j < smoothingFactor; j++) tempBodyFrames[j] = data.BodyFrames[i*smoothingFactor + j]; bodyFrames[i] = MoCapBodyFrame.Average(tempBodyFrames); } var faceFrames = new MoCapFaceFrame[data.FaceFrames.Length/smoothingFactor]; var tempFaceFrames = new MoCapFaceFrame[smoothingFactor]; for (var i = 0; i < data.FaceFrames.Length/smoothingFactor; i++) { for (var j = 0; j < smoothingFactor; j++) tempFaceFrames[j] = data.FaceFrames[i*smoothingFactor + j]; faceFrames[i] = MoCapFaceFrame.Average(tempFaceFrames); } data.BodyFrames = bodyFrames; data.FaceFrames = faceFrames; }
public static void Average(ref MoCapData data, int smoothingFactor) { if (data.BodyFrames == null || data.BodyFrames.Length == 0 || data.FaceFrames == null || data.FaceFrames.Length == 0) { throw new Exception("Invalid data!"); } if (smoothingFactor <= 0 || smoothingFactor > data.BodyFrames.Length || smoothingFactor > data.FaceFrames.Length) { throw new Exception("Invalid smoothing factor value!"); } var bodyFrames = new MoCapBodyFrame[data.BodyFrames.Length / smoothingFactor]; var tempBodyFrames = new MoCapBodyFrame[smoothingFactor]; for (var i = 0; i < data.BodyFrames.Length / smoothingFactor; i++) { for (var j = 0; j < smoothingFactor; j++) { tempBodyFrames[j] = data.BodyFrames[i * smoothingFactor + j]; } bodyFrames[i] = MoCapBodyFrame.Average(tempBodyFrames); } var faceFrames = new MoCapFaceFrame[data.FaceFrames.Length / smoothingFactor]; var tempFaceFrames = new MoCapFaceFrame[smoothingFactor]; for (var i = 0; i < data.FaceFrames.Length / smoothingFactor; i++) { for (var j = 0; j < smoothingFactor; j++) { tempFaceFrames[j] = data.FaceFrames[i * smoothingFactor + j]; } faceFrames[i] = MoCapFaceFrame.Average(tempFaceFrames); } data.BodyFrames = bodyFrames; data.FaceFrames = faceFrames; }
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); }