示例#1
0
        /// <summary>
        /// Stores Calibration Result into a XML file (probably sessions.xml)
        /// </summary>
        private void SaveCalibration()
        {
            CalibrationModel calibration = new CalibrationModel();

            calibration.CalSessionId = _selectedId;
            ConvertSelectedJoint();
            calibration.JointType        = _jointType;
            calibration.NumFrames        = NumFrames;
            calibration.Position         = CalibrationResult;
            calibration.SD               = CalibrationSD;
            calibration.Threshold        = CalibrationThreshold;
            calibration.InitialTime      = InitialTime;
            calibration.Estimated        = CalibrationEstimated;
            calibration.LeftShankLength  = LeftShankLength;
            calibration.LeftThighLength  = LeftThighLength;
            calibration.RightShankLength = RightShankLength;
            calibration.RightThighLength = RightThighLength;

            // Session is a member of SessionViewModel class. It was linked during constructor´s call
            // to LoadCalibration data.
            _sessionVM.SaveCalibrationData(xNode, calibration);

            // Update current session calibration values.

            if (_app.SessionsViewModel.CurrentSession != null)
            {
                _app.SessionsViewModel.CurrentSession.Calibration = calibration;
            }

            ProcessedFrames = 0;
            MessageBox.Show("Calibration saved.", "Calibration", MessageBoxButton.OK, MessageBoxImage.Information);
        }
示例#2
0
        private void CreateCalibrationEntry(ref XmlNode node, CalibrationModel c)
        {
            int j = (int)c.JointType;

            CreateAttribute(node, "JointType", j.ToString());

            CreateAttribute(node, "NumFrames", c.NumFrames.ToString());
            CreateAttribute(node, "InitialTime", c.InitialTime.ToString());

            CreateAttribute(node, "X", c.Position.X.ToString("0.00000"));
            CreateAttribute(node, "Y", c.Position.Y.ToString("0.00000"));
            CreateAttribute(node, "Z", c.Position.Z.ToString("0.00000"));

            CreateAttribute(node, "TX", c.Threshold.X.ToString("0.00000"));
            CreateAttribute(node, "TY", c.Threshold.Y.ToString("0.00000"));
            CreateAttribute(node, "TZ", c.Threshold.Z.ToString("0.00000"));

            CreateAttribute(node, "SDX", c.SD.X.ToString("0.00000"));
            CreateAttribute(node, "SDY", c.SD.Y.ToString("0.00000"));
            CreateAttribute(node, "SDZ", c.SD.Z.ToString("0.00000"));

            CreateAttribute(node, "EX", c.Estimated.X.ToString("0.00000"));
            CreateAttribute(node, "EY", c.Estimated.Y.ToString("0.00000"));
            CreateAttribute(node, "EZ", c.Estimated.Z.ToString("0.00000"));

            CreateAttribute(node, "LShank", c.LeftShankLength.ToString("0.000"));
            CreateAttribute(node, "LThigh", c.LeftThighLength.ToString("0.000"));
            CreateAttribute(node, "RShank", c.RightShankLength.ToString("0.000"));
            CreateAttribute(node, "RThigh", c.RightThighLength.ToString("0.000"));
        }
示例#3
0
        /// <summary>
        /// Constructor for playing back videos, show and collect data.
        /// </summary>
        /// <param name="videos">List of videos to be played</param>
        /// <param name="calibration">Calibration data</param>
        /// <param name="canvasImg">Pointer to RGB image</param>
        /// <param name="canvas">Pointer to skeleton</param>
        /// <param name="calling">Pointer to calling process</param>
        public SessionAnalysisKinect(ObservableCollection <VideoModel> videos, CalibrationModel calibration,
                                     Canvas canvasImg, Canvas canvas, Canvas filteredCanvas, AnalysisViewModel calling)
        {
            _canvas         = canvas;
            _canvasImg      = canvasImg;
            _calibration    = calibration;
            _filteredCanvas = filteredCanvas;

            _tracked    = 0;
            _notTracked = 0;
            frameCount  = 0;

            _defaultCanvas = _canvas;

            // If the session has no calibration initialize the instance.
            if (_calibration == null)
            {
                _calibration = new CalibrationModel()
                {
                    CalSessionId = 0,
                    JointType    = JointType.SpineBase,
                    Position     = new Vector3(0f, 0f, 0f)
                };
            }
            else
            {
                _Xthreshold = _calibration.Threshold.X;
            }

            // A reference to the calling process that receives and shows data.
            _callingProcess = calling;

            InitializeFilterARMA();
            HoltFilter = new KinectJointFilter();
            HoltFilter.Init(0.5f);

            _allRecords = new List <CameraSpacePoint[]>();

            //
            // This block bellow start Kinect device.
            //
            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _sensor.Open();
                _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Body | FrameSourceTypes.Color);
                _reader.MultiSourceFrameArrived += FrameArrived;
            }

            // Send the video list to be played.
            PlayVideoList(videos);
        }
示例#4
0
        /// <summary>
        /// Saves calibration information into session XML file.
        /// </summary>
        /// <param name="node">Parent session node</param>
        /// <param name="c">Calibration object that holds all calibration information to be stored</param>
        public void SaveCalibrationData(XmlNode node, CalibrationModel c)
        {
            XmlNode oldCalibration = node.SelectSingleNode("Calibration");

            if (oldCalibration != null)
            {
                oldCalibration.ParentNode.RemoveChild(oldCalibration);
            }

            XmlNode vNode = _xmlSessionDoc.CreateNode(XmlNodeType.Element, "Calibration", "");

            CreateCalibrationEntry(ref vNode, c);
            node.AppendChild(vNode);

            _xmlSessionDoc.Save(System.Configuration.ConfigurationManager.AppSettings["XmlSessionsFile"]);
        }