예제 #1
0
 public Interval(MicroPosture startMicroPosture, MicroPosture endMicroPosture)
 {
     //this.Item1 = Item1;
     //this.Item2 = Item2;
     StartTime = startMicroPosture.SceneLocationTime;
     EndTime   = endMicroPosture.SceneLocationTime;
     Duration  = EndTime.Subtract(StartTime);
     //PostureType = startMicroPosture.PostureType;
 }
예제 #2
0
        //public void showPersonInfo()
        //{
        //    IReadOnlyDictionary<PostureType, float> posturesAvg = this.calculatePosturesAverage();

        //    Console.WriteLine("Nombre: "+Name);
        //    Console.WriteLine("Genero: "+Gender.ToString("g"));
        //    Console.WriteLine("Edad: "+Age);

        //    foreach (PostureType posture in posturesAvg.Keys)
        //    {
        //        Console.WriteLine(posture.Name + ": " + posturesAvg[posture].ToString("0.00"));
        //    }

        //    ChartForm chartForm = new ChartForm(this);
        //    chartForm.Show();

        //}

        public void generatePostureIntervals()
        {
            if (this.MicroPostures.Count == 0)
            {
                return;
            }
            //Dictionary<string, string> dic = new Dictionary<string, string>();

            foreach (PostureType currentPostureType in PostureTypeContext.db.PostureType.ToList())
            {
                //System.Collections.IEnumerable microPostures = person.microPostures.Where(microPosture => microPosture.postureType.name == postureType.name);

                PostureIntervalGroup postureIntervalGroup = new PostureIntervalGroup(currentPostureType);
                MicroPosture         initialMicroPosture = null, lastMicroPosture = null;
                TimeSpan             threshold = TimeSpan.FromMilliseconds(Convert.ToDouble(Properties.Resources.PostureDurationDetectionThreshold));
                //bool moreThanOneInterval = false;
                //bool intervalOpen = false;

                foreach (MicroPosture microPosture in this.MicroPostures)
                {
                    if (microPosture.PostureType.Name != currentPostureType.Name)
                    {
                        continue;
                    }

                    if (lastMicroPosture == null)
                    {
                        initialMicroPosture = microPosture;
                        //intervalOpen = true;
                    }
                    else if (microPosture.SceneLocationTime.Subtract(lastMicroPosture.SceneLocationTime) >= threshold)
                    {
                        postureIntervalGroup.addInterval(initialMicroPosture, lastMicroPosture);
                        initialMicroPosture = microPosture;
                        //intervalOpen = true;
                    }
                    lastMicroPosture = microPosture;
                }
                if (initialMicroPosture != null)
                {
                    postureIntervalGroup.addInterval(initialMicroPosture, lastMicroPosture);
                }
                if (postureIntervalGroup.Intervals.Count > 0)
                {
                    this.PostureIntervalGroups.Add(postureIntervalGroup);
                }
            }
        }
예제 #3
0
        public void addInterval(MicroPosture initialMicroPosture, MicroPosture finalMicroPosture)
        {
            if (initialMicroPosture.PostureType != this.PostureType || finalMicroPosture.PostureType != this.PostureType)
            {
                //throw new Exception("You are adding an interval with diferent postureType to this IntervalPosture object");
                Console.WriteLine("ERROR!! : You are adding an interval with diferent postureType to this IntervalPosture object");
                return;
            }
            if (initialMicroPosture.SceneLocationTime >= finalMicroPosture.SceneLocationTime)
            {
                //throw new Exception("initialMicroPosture must be lower than finalMicroPosture");
                Console.WriteLine("ERROR!! : initialMicroPosture must be lower than finalMicroPosture");
                return;
            }
            bool exists = this.Intervals.Exists(
                interval =>
                //tuple.Item1.sceneLocationTime >= initialMicroPosture.sceneLocationTime ||
                interval.EndTime >= initialMicroPosture.SceneLocationTime
                );

            if (exists)
            {
                //throw new Exception("The initialMicroPosture must be greater than an existent finalMicroPosture interval");
                Console.WriteLine("ERROR!! : The initialMicroPosture must be greater than an existent finalMicroPosture interval");
            }
            int threshold = Convert.ToInt32(Properties.Resources.MinPostureIntervalDuration);

            if (finalMicroPosture.SceneLocationTime.Subtract(initialMicroPosture.SceneLocationTime).TotalMilliseconds >= threshold)
            {
                Intervals.Add(new Interval(initialMicroPosture, finalMicroPosture));
            }
            else
            {
                Console.WriteLine("### !! Interval SKIPPED!!: {0} - {1}", initialMicroPosture.SceneLocationTime, finalMicroPosture.SceneLocationTime);
            }
        }