/// <summary> /// Converts camera space point to color space, shows position to calling process and applies ARMA filter if the case. /// </summary> /// <param name="joint">Body joint</param> /// <param name="filter">ARMA filter reference to this joint</param> /// <returns></returns> private ColorSpacePoint ConvertJoint2ColorSpace(Joint joint, FilterARMA filter) { ColorSpacePoint point = new ColorSpacePoint(); if (joint.TrackingState == TrackingState.Tracked) { switch (joint.JointType) { case JointType.HipRight: _callingProcess.HipRightPosition = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z); break; case JointType.HipLeft: _callingProcess.HipLeftPosition = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z); break; case JointType.KneeRight: _callingProcess.KneeRightPosition = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z); break; case JointType.KneeLeft: _callingProcess.KneeLeftPosition = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z); break; case JointType.AnkleRight: _callingProcess.AnkleRightPosition = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z); break; case JointType.AnkleLeft: _callingProcess.AnkleLeftPosition = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z); break; } point = _sensor.CoordinateMapper.MapCameraPointToColorSpace(joint.Position); historyTrackedJoints[(int)joint.JointType] = point; if (filter != null) { filter.UpdateSerie(joint.Position); } } else { if (filter != null) { joint.Position = filter.PredictNextPoint(); point = _sensor.CoordinateMapper.MapCameraPointToColorSpace(joint.Position); } else { point = historyTrackedJoints[(int)joint.JointType]; } _notTracked++; } return(point); }
private void InitializeFilterARMA() { filtersARMA = new FilterARMA[Body.JointCount]; for (int i = 0; i < Body.JointCount; i++) { filtersARMA[i] = new FilterARMA(N); } }