コード例 #1
0
        Dictionary <ulong, int> getSegmentedUsers(int frameIndex)
        {
            int index = ListEx.GetMaxLessEqualIndexFromBinarySearch(_conversions.Keys.BinarySearch(frameIndex));

            if (index < 0 || index >= _conversions.Count)
            {
                return(new Dictionary <ulong, int>());
            }
            var dict = _conversions.Values[index];

            return(dict);
        }
コード例 #2
0
        /// <summary>
        /// 時刻を少しずつ進めながらフレームを作っていく
        /// </summary>
        /// <param name="records"></param>
        /// <returns></returns>
        private List <Frame> GenerateFrames()
        {
            List <Frame> frames = new List <Frame>();
            List <Tuple <List <DateTime>, int[]> > timeInfos = new List <Tuple <List <DateTime>, int[]> >();

            foreach (List <MotionData> record in this.originalRecords)
            {
                DateTime[] dateTimes = record.Select(m => m.TimeStamp).ToArray();
                int[]      indexes   = record.Select((m, i) => i).ToArray();
                Array.Sort(dateTimes, indexes);
                timeInfos.Add(Tuple.Create(dateTimes.ToList(), indexes));
            }
            this.timeInfos = timeInfos;

            for (DateTime time = this.startTime; time <= this.endTime; time += this.timePeriod)

            {
                // 同時刻のフレーム集合. Kinectの数だけ入るはず.
                List <MotionData> currentRecords = new List <MotionData>();
                List <MotionData> nextRecords    = new List <MotionData>();
                for (int i = 0; i < this.recordNum; i++)
                {
                    List <MotionData> record    = this.originalRecords[i];
                    List <DateTime>   dateTimes = timeInfos[i].Item1;
                    int[]             indexes   = timeInfos[i].Item2;
                    int frameIndex = ListEx.GetMaxLessEqualIndexFromBinarySearch(dateTimes.BinarySearch(time));
                    int nextIndex  = ListEx.GetMinGreaterEqualIndexFromBinarySearch(dateTimes.BinarySearch(time));
                    if (frameIndex < 0)
                    {
                        frameIndex = 0;
                    }
                    if (frameIndex >= record.Count())
                    {
                        frameIndex = record.Count() - 1;
                    }
                    if (nextIndex < 0)
                    {
                        nextIndex = 0;
                    }
                    if (nextIndex >= record.Count())
                    {
                        nextIndex = record.Count() - 1;
                    }
                    currentRecords.Add(record[indexes[frameIndex]]);
                    nextRecords.Add(record[indexes[nextIndex]]);
                }
                Frame frame = new Frame(currentRecords, nextRecords);
                frame.Time = time;
                frames.Add(frame);
            }
            return(frames);
        }
コード例 #3
0
        /// <summary>
        /// ある時刻の近傍で次のMotionDataを取ってくる
        /// </summary>
        /// <param name="recordNo"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public MotionData GetNextData(int recordNo, DateTime time)
        {
            List <MotionData> record    = this.originalRecords[recordNo];
            List <DateTime>   dateTimes = timeInfos[recordNo].Item1;

            int[] indexes   = timeInfos[recordNo].Item2;
            int   nextIndex = ListEx.GetMinGreaterEqualIndexFromBinarySearch(dateTimes.BinarySearch(time));

            if (nextIndex == indexes.Count())
            {
                return(null);
            }
            return(record[indexes[nextIndex]]);
        }
コード例 #4
0
        /// <summary>
        /// ある時刻の近傍で前のMotionDataを取ってくる
        /// </summary>
        /// <param name="recordNo"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public MotionData GetPrevData(int recordNo, DateTime time)
        {
            List <MotionData> record    = this.originalRecords[recordNo];
            List <DateTime>   dateTimes = timeInfos[recordNo].Item1;

            int[] indexes   = timeInfos[recordNo].Item2;
            int   prevIndex = ListEx.GetMaxLessEqualIndexFromBinarySearch(dateTimes.BinarySearch(time));

            if (prevIndex == -1)
            {
                return(null);
            }
            return(record[indexes[prevIndex]]);
        }
コード例 #5
0
        SortedList <int, Dictionary <ulong, int> > getSegmentedRange(int beginFrameIndex, int endFrameIndex)
        {
            int beginKey = ListEx.GetMaxLessEqualIndexFromBinarySearch(_conversions.Keys.BinarySearch(beginFrameIndex));
            int endKey   = ListEx.GetMinGreaterEqualIndexFromBinarySearch(_conversions.Keys.BinarySearch(endFrameIndex));
            SortedList <int, Dictionary <ulong, int> > ret = new SortedList <int, Dictionary <ulong, int> >();

            for (int key = beginKey; key < endKey; key++)
            {
                if (key >= 0)
                {
                    ret[_conversions.Keys[key]] = _conversions.Values[key];
                }
            }
            return(ret);
        }