Example #1
0
        public void WriteReport(DataClass.PersonInformation personInfo, DataClass.StdGaitParameters stdParm, DataClass.ObservedGaitParameters obsvParam)
        {
            XmlTextWriter writer = new XmlTextWriter("Report.xml", System.Text.Encoding.UTF8);

            writer.WriteStartDocument(true);
            writer.Formatting  = Formatting.Indented;
            writer.Indentation = 2;
            writer.WriteProcessingInstruction("xml-stylesheet", "type = 'text/xsl' href = 'Resources/HTMLReport.xsl'");
            writer.WriteStartElement("report");
            writer.WriteStartElement("summary");
            CreateSummaryNode(writer, personInfo);
            writer.WriteEndElement();
            writer.WriteStartElement("standardGaitParameters");
            CreateStandardGaitParameterNode(writer, stdParm);
            writer.WriteEndElement();
            writer.WriteStartElement("observedGaitParameters");
            CreateObservedGaitParameterNode(writer, obsvParam);
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Close();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            #region Read XML Files
            // creating XML reader object and reading person infromation from the correspoinding XML file
            personInformation = new DataClass.PersonInformation();
            XmlReader xmlPersonInfoReaderObj = new XmlReader(personInformationFileName);
            xmlPersonInfoReaderObj.ReadPersonInforamtionFile(personInformation);

            stdGaitParametes  = new DataClass.StdGaitParameters();
            obsvGaitParamters = new DataClass.ObservedGaitParameters();
            XmlReader xmlGaitPramReaderObj = new XmlReader(standardGaitParamterFileName);
            xmlGaitPramReaderObj.ReadStandardGaitPramFile(stdGaitParametes);
            xmlGaitPramReaderObj.InitializeObservedGaitParameters(obsvGaitParamters);
            #endregion

            #region Load Information Window
            Information infoForm = new Information();
            infoForm.ShowDialog();
            SavePersonInfromationFile();
            #endregion



            // Initialize the sensor
            if (personInformation.KinectVersionValue == "Kinect XBOX One (Kinect v2)")
            {
                sensor = KinectSensor.GetDefault();

                if (sensor != null)
                {
                    sensor.Open();
                    msfReader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth |
                                                                  FrameSourceTypes.Infrared | FrameSourceTypes.Body);
                    msfReader.MultiSourceFrameArrived += msfReader_MultiSourceFrameArrived;
                }
                //calculate focal lengths
                focalHorizontal = (float)(bmap.Width / (2 * Math.Tan(30 * Math.PI / 180)));
                focalVertical   = (float)(bmap.Height / (2 * Math.Tan(35 * Math.PI / 180)));
            }

            if (personInformation.KinectVersionValue == "Kinect Xbox 360 (Kinect v1)")
            {
                KinectV1Sensor v1Sensor;
                v1Sensor = KinectV1.KV1.GetDefault();
                if (v1Sensor != null)
                {
                    // Add the code for kinect v1
                    System.Windows.Forms.MessageBox.Show("V1 Detected!!");
                }
            }

            writeCoordinates = new StreamWriter(fs_jointData, System.Text.Encoding.ASCII);
            writeCoordinates.Write("Frame# , SpineBase_X, SpineBase_Y, SpineBase_Z , " +
                                   "SpineMid_X, SpineMid_Y, SpineMid_Z , Neck_X, Neck_Y, Neck_Z, Head_X, Head_Y, Head_Z," +
                                   "ShoulderLeft_X, ShoulderLeft_Y, ShoulderLeft_Z, EllowLeft_X, EllowLeft_Y, EllowLeft_Z," +
                                   "WristLeft_X, WristLeft_Y, WristLeft_Z,  HandLeft_X, HandLeft_Y, HandLeft_Z, " +
                                   "ShoulderRight_X, ShoulderRight_Y, ShoulderRight_Z, ElbowRight_X, ElbowRight_Y, ElbowRight_Z," +
                                   "WristRight_X, WristRight_Y, WristRight_Z, HandRight_X, HandRight_Y, HandRight_Z," +
                                   "HipLeft_X, HipLeft_Y, HipLeft_Z, KneeLeft_X, KneeLeft_Y, KneeLeft_Z, " +
                                   "AnkleLeft_X, AnkleLeft_Y, AnkleLeft_Z, FootLeft_X, FootLeft_Y, FootLeft_Z," +
                                   "HipRight_X, HipRight_Y, HipRight_Z, KneeRight_X, KneeRight_Y, KneeRight_Z, " +
                                   "AnkleRight_X, AnkleRight_Y, AnkleRight_Z, FootRight_X, FootRight_Y, FootRight_Z," +
                                   "SpineShoulder_X, SpineShoulder_Y, SpineShoulder_Z, HandTipLeft_X, HandTipLeft_Y, HandTipLeft_Z," +
                                   "ThumbLeft_X, ThumbLeft_Y, ThumbLeft_Z, HandTipRight_X, HandTipRight_Y, HandTipRight_Z," +
                                   "ThumbRight_X, ThumbRight_Y, ThumbRight_Z," + "," + bmap.Width + "," + bmap.Height + "," +
                                   focalHorizontal + "," + focalVertical + "," + Math.Tan(45 * Math.PI / 180));
            writeCoordinates.Write(Environment.NewLine);

            writeAngleData = new StreamWriter(fs_angleData, System.Text.Encoding.ASCII);
            writeAngleData.Write("Frame#, LeftKnee_FlexExt, RightKnee_FlexExt");
            writeAngleData.Write(Environment.NewLine);
        }