public XMLGenRecognizerOptionsWindow(XMLGenerator.RecognizerType type) { HideInsteadOfClosing = true; InitializeComponent(); measuringUnit.Items.Add("millimeter"); // No actual body measurement measuringUnit.SelectedIndex = 0; foreach (FubiUtils.BodyMeasurement measure in Enum.GetValues(typeof(FubiUtils.BodyMeasurement))) { if (measure != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { measuringUnit.Items.Add(FubiUtils.getBodyMeasureName(measure)); } } foreach (var measureName in Enum.GetNames(typeof(FubiUtils.DistanceMeasure))) { distanceMeasure.Items.Add(measureName); } distanceMeasure.SelectedIndex = (int)FubiUtils.DistanceMeasure.Euclidean; foreach (var typeName in XMLGenerator.ToleranceTypeString) { toleranceXType.Items.Add(typeName); toleranceYType.Items.Add(typeName); toleranceZType.Items.Add(typeName); toleranceDistType.Items.Add(typeName); toleranceSpeedType.Items.Add(typeName); toleranceFingerCountType.Items.Add(typeName); } toleranceXType.SelectedIndex = (int)XMLGenerator.ToleranceType.PlusMinus; toleranceYType.SelectedIndex = (int)XMLGenerator.ToleranceType.PlusMinus; toleranceZType.SelectedIndex = (int)XMLGenerator.ToleranceType.PlusMinus; toleranceDistType.SelectedIndex = (int)XMLGenerator.ToleranceType.PlusMinus; toleranceSpeedType.SelectedIndex = (int)XMLGenerator.ToleranceType.PlusMinus; toleranceFingerCountType.SelectedIndex = (int)XMLGenerator.ToleranceType.PlusMinus; Type = type; }
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); } }