Пример #1
0
        /// <summary>
        /// Called when page is loaded
        /// Initialize app assets such as skills
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            // Disable buttons while we initialize
            await UpdateMediaSourceButtonsAsync(false);

            // Initialize helper class used to render the skill results on screen
            m_bodyRenderer = new BodyRenderer(UICanvasOverlay);

            // Initialize skill-related instances and populate UI options
            m_lock.Wait();
            {
                NotifyUser("Initializing skill...");
                m_descriptor = new SkeletalDetectorDescriptor();
                m_availableExecutionDevices = await m_descriptor.GetSupportedExecutionDevicesAsync();

                await InitializeSkeletalDetectorAsync();
                await UpdateSkillUIAsync();
            }
            m_lock.Release();

            // Ready to begin, enable buttons
            NotifyUser("Skill initialized. Select a media source from the top to begin.");
            await UpdateMediaSourceButtonsAsync(true);
        }
Пример #2
0
        /// <summary>
        /// Triggered after the page has loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            // Initialize helper class used to render the skill results on screen
            m_bodyRenderer = new BodyRenderer(UICanvasOverlay);

            await Task.Run(async() =>
            {
                try
                {
                    m_skeletalDetectorDescriptor = new SkeletalDetectorDescriptor();
                    m_availableExecutionDevices  = await m_skeletalDetectorDescriptor.GetSupportedExecutionDevicesAsync();

                    // Refresh UI
                    await Dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.Normal,
                        () =>
                    {
                        // Show skill description members in UI
                        UISkillName.Text = m_skeletalDetectorDescriptor.Name;

                        UISkillDescription.Text = $"{m_skeletalDetectorDescriptor.Description}" +
                                                  $"\n\tauthored by: {m_skeletalDetectorDescriptor.Version.Author}" +
                                                  $"\n\tpublished by: {m_skeletalDetectorDescriptor.Version.Author}" +
                                                  $"\n\tversion: {m_skeletalDetectorDescriptor.Version.Major}.{m_skeletalDetectorDescriptor.Version.Minor}" +
                                                  $"\n\tunique ID: {m_skeletalDetectorDescriptor.Id}";

                        var inputDesc = m_skeletalDetectorDescriptor.InputFeatureDescriptors[0] as SkillFeatureImageDescriptor;
                        UISkillInputDescription.Text = $"\tName: {inputDesc.Name}" +
                                                       $"\n\tDescription: {inputDesc.Description}" +
                                                       $"\n\tType: {inputDesc.FeatureKind}" +
                                                       $"\n\tWidth: {inputDesc.Width}" +
                                                       $"\n\tHeight: {inputDesc.Height}" +
                                                       $"\n\tSupportedBitmapPixelFormat: {inputDesc.SupportedBitmapPixelFormat}" +
                                                       $"\n\tSupportedBitmapAlphaMode: {inputDesc.SupportedBitmapAlphaMode}";

                        var outputDesc1 = m_skeletalDetectorDescriptor.OutputFeatureDescriptors[0] as SkeletalDetectorResultListDescriptor;
                        UISkillOutputDescription1.Text = $"\tName: {outputDesc1.Name}, Description: {outputDesc1.Description} \n\tType: Custom";

                        if (m_availableExecutionDevices.Count == 0)
                        {
                            UISkillOutputDetails.Text = "No execution devices available, this skill cannot run on this device";
                        }
                        else
                        {
                            // Display available execution devices
                            UISkillExecutionDevices.ItemsSource   = m_availableExecutionDevices.Select((device) => device.Name);
                            UISkillExecutionDevices.SelectedIndex = 0;

                            // Alow user to interact with the app
                            UIButtonFilePick.IsEnabled = true;
                            UICameraToggle.IsEnabled   = true;
                            UIButtonFilePick.Focus(FocusState.Keyboard);
                        }
                    });
                }
                catch (Exception ex)
                {
                    await new MessageDialog(ex.Message).ShowAsync();
                }
            });

            // Register callback for if camera preview encounters an issue
            UICameraPreview.PreviewFailed += UICameraPreview_PreviewFailed;
        }