protected override void generateXML() { if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } if (Options.SelectedJoints.Count == 1) { var jointNode = Doc.CreateElement(UseHand ? "HandJoint" : "Joint", NamespaceUri); appendStringAttribute(jointNode, "name", getJointName(Options.SelectedJoints[0].Main)); RecognizerNode.AppendChild(jointNode); } var fingerCountNode = Doc.CreateElement("FingerCount", NamespaceUri); if (Options.ToleranceCountType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(fingerCountNode, "min", Math.Max(0, m_avgFingerCount - Options.ToleranceCount)); } if (Options.ToleranceCountType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(fingerCountNode, "max", Math.Min(5, m_avgFingerCount + Options.ToleranceCount)); } if (Options.MedianWindowSize > 0) { appendStringAttribute(fingerCountNode, "useMedianCalculation", "true"); appendNumericAttribute(fingerCountNode, "medianWindowSize", Options.MedianWindowSize, 0); } RecognizerNode.AppendChild(fingerCountNode); }
protected override void generateXML() { for (var i = 0; i < CombOptions.States.Count; i++) { if (CombOptions.States[i].Recognizers.Count > 0) // Skip emtpy states { var stateNode = Doc.CreateElement("State", NamespaceUri); foreach (var recognizer in CombOptions.States[i].Recognizers) { var recNode = Doc.CreateElement("Recognizer", NamespaceUri); appendStringAttribute(recNode, "name", recognizer); stateNode.AppendChild(recNode); } var minDuration = CombOptions.States[i].MinDuration - CombOptions.TimeTolerance; if (minDuration > 0 && CombOptions.TimeToleranceType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(stateNode, "minDuration", minDuration, 3); } if (CombOptions.States[i].MaxDuration >= 0 && CombOptions.TimeToleranceType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(stateNode, "maxDuration", CombOptions.States[i].MaxDuration + CombOptions.TimeTolerance, 3); } if (i != CombOptions.States.Count - 1 && CombOptions.States[i].TimeForTransition >= 0) { appendNumericAttribute(stateNode, "timeForTransition", CombOptions.States[i].TimeForTransition + CombOptions.TransitionTolerance, 3); } RecognizerNode.AppendChild(stateNode); } } }
protected override void generateXML() { if (!Options.Local) { appendStringAttribute(RecognizerNode, "useLocalOrientations", "false"); } if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } var jointNode = Doc.CreateElement(UseHand ? "HandJoint" : "Joint", NamespaceUri); appendStringAttribute(jointNode, "name", getJointName(Options.SelectedJoints[0].Main)); RecognizerNode.AppendChild(jointNode); var maxVelocity = Doc.CreateElement("MaxAngularVelocity", NamespaceUri); var minVelocity = Doc.CreateElement("MinAngularVelocity", NamespaceUri); if (Options.ToleranceX >= 0) { if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxVelocity, "x", (AvgValue.X + Options.ToleranceX)); } if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minVelocity, "x", (AvgValue.X - Options.ToleranceX)); } } if (Options.ToleranceY >= 0) { if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxVelocity, "y", (AvgValue.Y + Options.ToleranceY)); } if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minVelocity, "y", (AvgValue.Y - Options.ToleranceY)); } } if (Options.ToleranceZ >= 0) { if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxVelocity, "z", (AvgValue.Z + Options.ToleranceZ)); } if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minVelocity, "z", (AvgValue.Z - Options.ToleranceZ)); } } if (maxVelocity.HasAttributes) { RecognizerNode.AppendChild(maxVelocity); } if (minVelocity.HasAttributes) { RecognizerNode.AppendChild(minVelocity); } }
protected override void generateXML() { if (Options.Local) { appendStringAttribute(RecognizerNode, "useLocalPositions", "true"); } if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { appendStringAttribute(RecognizerNode, "measuringUnit", FubiUtils.getBodyMeasureName(Options.MeasuringUnit)); } var jointNode = Doc.CreateElement(UseHand ? "HandJoints" : "Joints", NamespaceUri); appendStringAttribute(jointNode, "main", getJointName(Options.SelectedJoints[0].Main)); if (Options.SelectedJoints[0].Relative != FubiUtils.SkeletonJoint.NUM_JOINTS) { appendStringAttribute(jointNode, "relative", getJointName(Options.SelectedJoints[0].Relative)); } RecognizerNode.AppendChild(jointNode); Vector3D direction = AvgValue; double length = AvgValue.Length; if (length > Double.Epsilon) { direction.Normalize(); } else // No valid direction recorded, so we arbitrarily chose up direction { direction = new Vector3D(0, 1, 0); } var directionNode = Doc.CreateElement("Direction", NamespaceUri); appendNumericAttribute(directionNode, "x", direction.X, 3); appendNumericAttribute(directionNode, "y", direction.Y, 3); appendNumericAttribute(directionNode, "z", direction.Z, 3); if (Options.MaxAngleDifference >= 0) { appendNumericAttribute(directionNode, "maxAngleDifference", Options.MaxAngleDifference, 3); } RecognizerNode.AppendChild(directionNode); if (Options.ToleranceDist >= 0) { if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { if (m_measureDist > 0) { AvgValue.X /= m_measureDist; AvgValue.Y /= m_measureDist; AvgValue.Z /= m_measureDist; length = AvgValue.Length; } } var lengthNode = Doc.CreateElement("Length", NamespaceUri); if (length - Options.ToleranceDist > 0 && Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(lengthNode, "min", length - Options.ToleranceDist, 3); } if (Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(lengthNode, "max", length + Options.ToleranceDist, 3); } if (lengthNode.HasAttributes) { RecognizerNode.AppendChild(lengthNode); } } if (Options.ToleranceSpeed >= 0) { var speedNode = Doc.CreateElement("Speed", NamespaceUri); if (m_speed - Options.ToleranceSpeed > 0 && Options.ToleranceSpeedType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(speedNode, "min", m_speed - Options.ToleranceSpeed, 3); } if (Options.ToleranceSpeedType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(speedNode, "max", m_speed + Options.ToleranceSpeed, 3); } if (speedNode.HasAttributes) { RecognizerNode.AppendChild(speedNode); } } }
protected override void generateXML() { if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } XmlElement maxNode, minNode; if (Type == XMLGenerator.RecognizerType.JointRelation) { if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { appendStringAttribute(RecognizerNode, "measuringUnit", FubiUtils.getBodyMeasureName(Options.MeasuringUnit)); } if (Options.Local) { appendStringAttribute(RecognizerNode, "useLocalPositions", "true"); } var jointNode = Doc.CreateElement(UseHand ? "HandJoints" : "Joints", NamespaceUri); appendStringAttribute(jointNode, "main", getJointName(Options.SelectedJoints[0].Main)); if (Options.SelectedJoints[0].Relative != FubiUtils.SkeletonJoint.NUM_JOINTS) { appendStringAttribute(jointNode, "relative", getJointName(Options.SelectedJoints[0].Relative)); } RecognizerNode.AppendChild(jointNode); maxNode = Doc.CreateElement("MaxValues", NamespaceUri); minNode = Doc.CreateElement("MinValues", NamespaceUri); } else { if (!Options.Local) { appendStringAttribute(RecognizerNode, "useLocalOrientations", "false"); } var jointNode = Doc.CreateElement(UseHand ? "HandJoint" : "Joint", NamespaceUri); appendStringAttribute(jointNode, "name", getJointName(Options.SelectedJoints[0].Main)); RecognizerNode.AppendChild(jointNode); if (Options.MaxAngleDifference >= 0) { var orientationNode = Doc.CreateElement("Orientation", NamespaceUri); appendNumericAttribute(orientationNode, "x", AvgValue.X); appendNumericAttribute(orientationNode, "y", AvgValue.Y); appendNumericAttribute(orientationNode, "z", AvgValue.Z); appendNumericAttribute(orientationNode, "maxAngleDifference", Options.MaxAngleDifference); RecognizerNode.AppendChild(orientationNode); return; } maxNode = Doc.CreateElement("MaxDegrees", NamespaceUri); minNode = Doc.CreateElement("MinDegrees", NamespaceUri); } if (Options.ToleranceX >= 0) { if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "x", AvgValue.X + Options.ToleranceX); } if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minNode, "x", AvgValue.X - Options.ToleranceX); } } if (Options.ToleranceY >= 0) { if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "y", AvgValue.Y + Options.ToleranceY); } if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minNode, "y", AvgValue.Y - Options.ToleranceY); } } if (Options.ToleranceZ >= 0) { if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "z", AvgValue.Z + Options.ToleranceZ); } if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minNode, "z", AvgValue.Z - Options.ToleranceZ); } } if (Type == XMLGenerator.RecognizerType.JointRelation && Options.ToleranceDist >= 0) { var dist = AvgValue.Length; if (Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "dist", dist + Options.ToleranceDist); } if (Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { var minDist = dist - Options.ToleranceDist; if (minDist > 0) { appendNumericAttribute(minNode, "dist", minDist); } } } if (maxNode.HasAttributes) { RecognizerNode.AppendChild(maxNode); } if (minNode.HasAttributes) { RecognizerNode.AppendChild(minNode); } }
protected override void generateXML() { if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { appendStringAttribute(RecognizerNode, "measuringUnit", FubiUtils.getBodyMeasureName(Options.MeasuringUnit)); } if (Options.Local) { appendStringAttribute(RecognizerNode, "useLocalTransformations", "true"); } if (Options.MaxAngleDifference >= 0) { appendNumericAttribute(RecognizerNode, "maxRotation", Options.MaxAngleDifference, 3); } appendNumericAttribute(RecognizerNode, "maxDistance", Options.MaxDistance, 3); appendStringAttribute(RecognizerNode, "distanceMeasure", Options.DistanceMeasure.ToString().ToLower()); if (Options.UseOrientations) { appendStringAttribute(RecognizerNode, "useOrientations", "true"); } if (Options.AspectInvariant) { appendStringAttribute(RecognizerNode, "aspectInvariant", "true"); } foreach (XMLGenerator.RelativeJoint j in Options.SelectedJoints) { var jointNode = Doc.CreateElement(UseHand ? "HandJoints" : "Joints", NamespaceUri); appendStringAttribute(jointNode, "main", getJointName(j.Main)); if (j.Relative != FubiUtils.SkeletonJoint.NUM_JOINTS) { appendStringAttribute(jointNode, "relative", getJointName(j.Relative)); } RecognizerNode.AppendChild(jointNode); } var trainingNode = Doc.CreateElement("TrainingData", NamespaceUri); appendStringAttribute(trainingNode, "file", Options.PlaybackFile); appendNumericAttribute(trainingNode, "start", Options.PlaybackStart, 0); appendNumericAttribute(trainingNode, "end", Options.PlaybackEnd, 0); RecognizerNode.AppendChild(trainingNode); if (Options.IgnoreAxes != 0) { var ignoreAxesNode = Doc.CreateElement("IgnoreAxes", NamespaceUri); if ((Options.IgnoreAxes & (uint)FubiUtils.CoordinateAxis.X) != 0) { appendStringAttribute(ignoreAxesNode, "x", "true"); } if ((Options.IgnoreAxes & (uint)FubiUtils.CoordinateAxis.Y) != 0) { appendStringAttribute(ignoreAxesNode, "y", "true"); } if ((Options.IgnoreAxes & (uint)FubiUtils.CoordinateAxis.Z) != 0) { appendStringAttribute(ignoreAxesNode, "z", "true"); } RecognizerNode.AppendChild(ignoreAxesNode); } }