예제 #1
0
        public FFTStats(Trajectory trajectory, EDirection direction, bool useSlope)
        {
            var points = (useSlope) ? trajectory.slopes : trajectory.points;
            var xList  = (direction == EDirection.Z) ? points.Select(p => p.z).ToArray() : points.Select(p => p.x).ToArray();
            var zList  = (direction == EDirection.X) ? points.Select(p => p.x).ToArray() : points.Select(p => p.z).ToArray();

            dataXList = DoubleArray.From(xList);
            dataZList = DoubleArray.From(zList);
            signal    = GetSignal(dataXList, dataZList);
            duration  = trajectory.duratation();
            GetPxxFx(signal, out Pxx, out Fx);
        }
        public override List <Tuple <Trajectory, ESegmentType> > segmentTrajectory(Trajectory trajectory)
        {
            List <Tuple <Trajectory, ESegmentType> > segments = new List <Tuple <Trajectory, ESegmentType> >();
            double closeThreshold = 1.5;
            double farThreshold   = 7.5;

            Double.TryParse(ConfigurationManager.AppSettings["SegmentedGaitFarThreshold"], out farThreshold);
            Double.TryParse(ConfigurationManager.AppSettings["SegmentedGaitCloseThreshold"], out closeThreshold);

            Trajectory t             = null;
            long       lastTimeStamp = -1000;
            int        pointNumber   = -1;

            foreach (var p in trajectory.points)
            {
                pointNumber++;
                if (p.z < closeThreshold)
                {
                    continue;
                }
                if (p.z > farThreshold)
                {
                    continue;
                }
                if (p.timeStamp - lastTimeStamp > 1000)
                {
                    if ((t != null) && (t.duratation() > 1.0))
                    {
                        segments.Add(new Tuple <Trajectory, ESegmentType>(t, ESegmentType.Walking));
                    }
                    t = new Trajectory();
                    t.samplingRate = trajectory.samplingRate;
                }
                t.add(p, trajectory.slopes[pointNumber]);
                lastTimeStamp = p.timeStamp;
            }
            if ((t != null) && (t.duratation() > 1.0))
            {
                segments.Add(new Tuple <Trajectory, ESegmentType>(t, ESegmentType.Walking));
            }

            return(segments);
        }
예제 #3
0
        private List <Metric> analyzeSharedMetrics(List <Tuple <Trajectory, ESegmentType> > segments, Trajectory trajectory)
        {
            List <Metric> metrics = new List <Metric>();

            //Time domain stats
            metrics.Add(new Metric
            {
                name  = "Duration",
                value = trajectory.duratation()
            });

            metrics.Add(new Metric
            {
                name  = "Frames Per Second",
                value = segments.Sum(s => s.Item1.points.Count) / segments.Sum(s => s.Item1.duratation())
            });

            return(metrics);
        }
예제 #4
0
        public override List <Tuple <Trajectory, ESegmentType> > segmentTrajectory(Trajectory trajectory)
        {
            List <Tuple <Trajectory, ESegmentType> > segments = new List <Tuple <Trajectory, ESegmentType> >();
            var state          = Estate.GoingAway;
            var closeThreshold = 2.5;
            var farThreshold   = 6.5;
            var hysteresis     = 0.05;

            Double.TryParse(ConfigurationManager.AppSettings["closeThreshold"], out closeThreshold);
            Double.TryParse(ConfigurationManager.AppSettings["farThreshold"], out farThreshold);
            Double.TryParse(ConfigurationManager.AppSettings["hysteresis"], out hysteresis);
            string initialState = ConfigurationManager.AppSettings["initialState"];

            switch (initialState)
            {
            case "GettingCloser": state = Estate.GettingCloser; break;

            case "GoingAway": state = Estate.GoingAway; break;

            case "TurningClose": state = Estate.TurningClose; break;

            case "TurningFar": state = Estate.TurningFar; break;
            }
            Trajectory t = new Trajectory();

            t.samplingRate = trajectory.samplingRate;
            int pointNumber = -1;

            foreach (var p in trajectory.points)
            {
                pointNumber++;
                if (p.z < closeThreshold - hysteresis && state == Estate.GettingCloser)
                {
                    state = Estate.TurningClose;
                    if (t.duratation() > 0)
                    {
                        segments.Add(new Tuple <Trajectory, ESegmentType>(t, ESegmentType.Walking));
                    }
                    t = new Trajectory();
                    t.samplingRate = trajectory.samplingRate;
                }
                else if (p.z > farThreshold + hysteresis && state == Estate.GoingAway)
                {
                    state = Estate.TurningFar;
                    if (t.duratation() > 0)
                    {
                        segments.Add(new Tuple <Trajectory, ESegmentType>(t, ESegmentType.Walking));
                    }
                    t = new Trajectory();
                    t.samplingRate = trajectory.samplingRate;
                }
                else if (p.z > closeThreshold + hysteresis && state == Estate.TurningClose)
                {
                    state = Estate.GoingAway;
                    if (t.duratation() > 0)
                    {
                        segments.Add(new Tuple <Trajectory, ESegmentType>(t, ESegmentType.Turning));
                    }
                    t = new Trajectory();
                    t.samplingRate = trajectory.samplingRate;
                }
                else if (p.z < farThreshold - hysteresis && state == Estate.TurningFar)
                {
                    state = Estate.GettingCloser;
                    if (t.duratation() > 0)
                    {
                        segments.Add(new Tuple <Trajectory, ESegmentType>(t, ESegmentType.Turning));
                    }
                    t = new Trajectory();
                    t.samplingRate = trajectory.samplingRate;
                }
                t.add(p, trajectory.slopes[pointNumber]);
            }
            return(segments);
        }