public void LoadVideo()
        {
            var selectedCamera = this._screen.SelectedCamera;

            if (selectedCamera == null)
            {
                return;
            }

            var range         = this._screen.TimeRange;
            var type          = this._screen.SearchScope;
            var frameQuery    = _portraitRepository.GetFrames(selectedCamera.Id, range).ToArray();
            var portraitQuery = _portraitRepository.GetPortraits(selectedCamera.Id, range).ToArray();

            Core.Video v;
            this._screen.ClearAll();

            for (int i = currentPage * PageSize; i < currentPage * PageSize + PageSize; i++)
            {
                if (i >= TotalCount)
                {
                    break;
                }
                v = TotalVideos[i];
                var queryTime = new DateTimeRange(v.CapturedAt, v.CapturedAt);
                v.HasMotionDetected = frameQuery.FirstOrDefault(f => f.CapturedAt.RoundToMinute() == v.CapturedAt.RoundToMinute()) != null;
                v.HasFaceCaptured   = portraitQuery.FirstOrDefault(p => p.CapturedAt.RoundToMinute() == v.CapturedAt.RoundToMinute()) != null;
                if ((type & SearchScope.FaceCapturedVideo)
                    == SearchScope.FaceCapturedVideo)
                {
                    if (v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((type & SearchScope.MotionWithoutFaceVideo)
                    == SearchScope.MotionWithoutFaceVideo)
                {
                    if (v.HasMotionDetected && !v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((type & SearchScope.MotionLessVideo)
                    == SearchScope.MotionLessVideo)
                {
                    if (!v.HasFaceCaptured && !v.HasMotionDetected)
                    {
                        _screen.AddVideo(v);
                    }
                }
            }
        }
示例#2
0
        private void DoSearch()
        {
            var videos =
                new FileSystemStorage(
                    Properties.Settings.Default.OutputPath).
                VideoFilesBetween(_selectedCamera.Id,
                                  _currentRange.From, _currentRange.To).ToList();

            var watch = System.Diagnostics.Stopwatch.StartNew();
            var range = new DateTimeRange(_currentRange.From, _currentRange.To.AddMinutes(1));

            watch.Stop();
            System.Diagnostics.Debug.WriteLine("frames search took " + watch.Elapsed);

            watch.Start();

            _portraits = new XPCollection <Portrait>();
            var cretia = CriteriaOperator.Parse("CaptureTime >= ? and CaptureTime < ?",
                                                range.From, range.To);

            _portraits.Criteria = cretia;
            _portraits.Load();

            var gq = from item in _portraits
                     group item by item.CaptureTime.Date.AddHours(item.CaptureTime.Hour).AddMinutes(item.CaptureTime.Minute) into g
                     orderby g.Key ascending
                     select g;

            watch.Stop();
            System.Diagnostics.Debug.WriteLine("portraits search took " + watch.Elapsed);

            this._screen.ClearAll();

            foreach (var v in videos)
            {
                if (v.CapturedAt.Ticks < _currentRange.From.Ticks || v.CapturedAt.Ticks > _currentRange.To.Ticks)
                {
                    continue;
                }

                v.HasFaceCaptured = gq.Where(g => g.Key == v.CapturedAt).Count() != 0;

                if ((_scope & SearchScope.FaceCapturedVideo)
                    == SearchScope.FaceCapturedVideo)
                {
                    if (v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((_scope & SearchScope.MotionWithoutFaceVideo)
                    == SearchScope.MotionWithoutFaceVideo)
                {
                    if (v.HasMotionDetected && !v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((_scope & SearchScope.MotionLessVideo)
                    == SearchScope.MotionLessVideo)
                {
                    if (!v.HasFaceCaptured &&
                        !v.HasMotionDetected)
                    {
                        _screen.AddVideo(v);
                    }
                }
            }
        }