public void RetrainRecognizer()
        {
            TrainRecognizer(_parameters.RecognizerIndex);

            _controls.StatusText  = StatusTypes.RetrainCompleted.GetDesciption();
            _controls.IsNewUpdate = true;

            StatusBarUtility.ResestStatus(_controls);
        }
Пример #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            await StatusBarUtility.ShowAsync();

            if (e.NavigationMode == NavigationMode.Back)
            {
                ViewModel.CheckCurrentActivitiesAsync();
            }
            base.OnNavigatedTo(e);
        }
Пример #3
0
        protected override async void NavigationActionAsync(object state)
        {
            await StatusBarUtility.ShowAsync();

            ContentPageArgs args = new ContentPageArgs()
            {
                Name             = "登录",
                HeaderVisibility = Visibility.Collapsed,
            };

            args.ContentElement = new LoginFirstStepContentView();

            TryReplaceNavigate(typeof(ContentPageView), args);
        }
Пример #4
0
        public void ToogleCameraService()
        {
            if (!IsStarted())
            {
                Task.Delay(700).ContinueWith(_ =>
                {
                    StartCapturing(_parameters.DeviceIndex);

                    _controls.IsDeviceChangeEnabled = false;
                    _controls.ServiceButtonText     = ButtonText.NoRetrieve.GetDesciption();
                    _controls.Name    = string.Empty;
                    _controls.Age     = string.Empty;
                    _controls.Address = string.Empty;
                    _controls.Details = string.Empty;

                    _controls.StatusText  = StatusTypes.StreamStarted.GetDesciption();
                    _controls.IsNewUpdate = true;

                    _controls.IsSaveEnabled = false;

                    StatusBarUtility.ResestStatus(_controls);
                });
            }
            else
            {
                StopCapturing();

                _controls.IsDeviceChangeEnabled = true;
                _controls.ServiceButtonText     = ButtonText.Retrieve.GetDesciption();
                _controls.KnownPeople           = _parameters.UseExplorer
                    ? _localStorageService.GetPeopleNames()
                    : _databaseService.GetPeopleNames();

                _controls.StatusText  = StatusTypes.StreamPaused.GetDesciption();
                _controls.IsNewUpdate = true;

                if (_controls.TheNewestFace != null)
                {
                    _controls.IsSaveEnabled = true;
                }

                StatusBarUtility.ResestStatus(_controls);
            }
        }
Пример #5
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                BaseViewModel.SetMainWindow();
                BaseViewModel.SetOfoWebApiInstance(Global.OfoApi);

                StatusBarUtility.SetForeground(Colors.DimGray);

                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    rootFrame.Navigate(typeof(LoadingView), e.Arguments);
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
            }
        }
Пример #6
0
        public void SaveDetected()
        {
            var person = new PersonModelBase()
            {
                Name    = _controls.Name,
                Age     = Convert.ToInt32(_controls.Age),
                Address = _controls.Address,
                Details = _controls.Details
            };

            var image = new ImageModelBase()
            {
                Data = BitmapUtility.BitmapToByteArray(_controls.TheNewestFace)
            };

            try
            {
                if (_parameters.UseExplorer)
                {
                    _localStorageService.SaveFace(person, image);
                }
                else
                {
                    _databaseService.SaveFace(new PersonModel(person), new ImageModel(image));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Wystąpił błąd podczas zapisu do bazy danych\r\n\r\n" + e);
            }

            _controls.KnownPeople = _parameters.UseExplorer
                ? _localStorageService.GetPeopleNames()
                : _databaseService.GetPeopleNames();
            _controls.StatusText  = StatusTypes.SaveCompleted.GetDesciption();
            _controls.IsNewUpdate = true;

            StatusBarUtility.ResestStatus(_controls);
        }
Пример #7
0
        private void _faceDetectionService_FaceDetected(object sender, Image <Bgr, byte> image, Bitmap bitmap)
        {
            _mainPageViewModel.ViewModel.MainControls.TheNewestFace = bitmap;
            _mainPageViewModel.ViewModel.MainControls.StatusText    = StatusTypes.FaceDetected.GetDesciption();
            _mainPageViewModel.ViewModel.MainControls.IsNewUpdate   = true;

            var id = _faceRecognionService.RecognizePerson(image.Convert <Gray, byte>(),
                                                           _mainPageViewModel.ViewModel.Parameters.RecognizerIndex);
            var person = _databaseService.GetPersonalData(id);

            _mainPageViewModel.ViewModel.MainControls.DetectedId   = id;
            _mainPageViewModel.ViewModel.MainControls.DetectedName =
                person != null ? person.Name : "Brak informacji";
            _mainPageViewModel.ViewModel.MainControls.DetectedAge =
                person != null?person.Age.ToString() : "";

            _mainPageViewModel.ViewModel.MainControls.DetectedAddress =
                person != null ? person.Address : "";
            _mainPageViewModel.ViewModel.MainControls.DetectedDetails =
                person != null ? person.Details : "";

            StatusBarUtility.ResestStatus(_mainPageViewModel.ViewModel.MainControls);
        }