コード例 #1
0
        private async Task InitializeScreenAsync()
        {
            CameraHelperResult result = await CameraService.Current.InitializeAsync();

            if (result != CameraHelperResult.Success)
            {
                await MessageDialogService.Current.WriteMessage(result.ToString() + GameText.LOADER.GetString("CameraHelperResultFailed"));

                return;
            }

            bool isModelLoaded = await IntelligenceService.Current.InitializeAsync();

            if (!isModelLoaded)
            {
                await MessageDialogService.Current.WriteMessage(GameText.LOADER.GetString("ModelLoadedFailed"));

                return;
            }
            IntelligenceService.Current.IntelligenceServiceEmotionClassified += Current_IntelligenceServiceEmotionClassified;

            await instructions.Fade(value : 0.0f, duration : 1000, delay : 0).StartAsync();

            instructions.Text = GameText.LOADER.GetString("FirstScreenInstructionsAfterInitialization");
            await instructions.Fade(value : 1.0f, duration : 250, delay : 0).StartAsync();

            _isInitialized        = true;
            StartButton.IsEnabled = true;
        }
コード例 #2
0
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            _previewImageSource = new SoftwareBitmapSource();
            PreviewImage.Source = _previewImageSource;
            _cameraHelper       = new CameraHelper();

            IReadOnlyList <MediaFrameSourceGroup> frameSourceGroups = await CameraHelper.GetFrameSourceGroupsAsync();

            CameraHelperResult result = await _cameraHelper.InitializeAndStartCaptureAsync();

            if (result == CameraHelperResult.Success)
            {
                // Subscribe to the video frame as they arrive
                _cameraHelper.FrameArrived             += CameraHelper_FrameArrived;
                FrameSourceGroupCombo.ItemsSource       = frameSourceGroups;
                FrameSourceGroupCombo.SelectionChanged += FrameSourceGroupCombo_SelectionChanged;

                MediaFrameSource frameSource = _cameraHelper.PreviewFrameSource;
                _mediaPlayer = new MediaPlayer {
                    AutoPlay = true, RealTimePlayback = true
                };
                _mediaPlayer.Source = MediaSource.CreateFromMediaFrameSource(frameSource);
                MediaPlayerElementControl.SetMediaPlayer(_mediaPlayer);

                FrameSourceGroupCombo.SelectedIndex = 0;
            }
        }
コード例 #3
0
        private async void FrameSourceGroupCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (FrameSourceGroupCombo.SelectedItem is MediaFrameSourceGroup selectedGroup)
            {
                _cameraHelper.FrameSourceGroup = selectedGroup;
                CameraHelperResult result = await _cameraHelper.InitializeAndStartCaptureAsync();

                MediaFrameSource frameSource = _cameraHelper.PreviewFrameSource;
                //_mediaPlayer = new MediaPlayer { AutoPlay = true, RealTimePlayback = true };
                _mediaPlayer.Source = MediaSource.CreateFromMediaFrameSource(frameSource);
                MediaPlayerElementControl.SetMediaPlayer(_mediaPlayer);
            }
        }
コード例 #4
0
        private void SetUIControls(CameraHelperResult result)
        {
            var success = result == CameraHelperResult.Success;

            if (!success)
            {
                _currentVideoFrame = null;
            }

            CameraErrorTextBlock.Text       = result.ToString();
            CameraErrorTextBlock.Visibility = success ? Visibility.Collapsed : Visibility.Visible;

            CaptureButton.IsEnabled   = success;
            CurrentFrameImage.Opacity = success ? 1 : 0.5;
        }
コード例 #5
0
        private async Task InitializeScreenAsync()
        {
            CameraHelperResult result = await CameraService.Current.InitializeAsync();

            if (result != CameraHelperResult.Success)
            {
                await MessageDialogService.Current.WriteMessage(result.ToString() + GameText.LOADER.GetString("CameraHelperResultFailed"));

                return;
            }

            bool isModelLoaded = await IntelligenceService.Current.InitializeAsync();

            if (!isModelLoaded)
            {
                await MessageDialogService.Current.WriteMessage(GameText.LOADER.GetString("ModelLoadedFailed"));

                return;
            }
            IntelligenceService.Current.ScoreUpdated += UpdatePredictionRadialGaugeValue;

            //need dummy current emoji placeholder to start
            if (!_isPaused)
            {
                CurrentEmojis._currentEmoji = null;
            }

            //maintain results emojis if app is suspended and resumed
            if (!_isPaused)
            {
                _resultsEmojis = new List <Emoji>();
            }

            //to avoid initial interval delay, make first UI update here
            await UpdateNonPredictionBasedUIAsync();

            _isInitialized = true;
        }
コード例 #6
0
        private async Task InitializeScreenAsync()
        {
            CameraHelperResult result = await CameraService.Current.InitializeAsync();

            if (result != CameraHelperResult.Success)
            {
                await MessageDialogService.Current.WriteMessage(result.ToString() + GameText.LOADER.GetString("CameraHelperResultFailed"));

                return;
            }

            bool isModelLoaded = await IntelligenceService.Current.InitializeAsync();

            if (!isModelLoaded)
            {
                await MessageDialogService.Current.WriteMessage(GameText.LOADER.GetString("ModelLoadedFailed"));

                return;
            }
            IntelligenceService.Current.IntelligenceServiceEmotionClassified += Current_IntelligenceServiceEmotionClassified;

            _isInitialized = true;
        }