/// <summary> /// Triggered on page loaded. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Page_Loaded(object sender, RoutedEventArgs e) { // Refresh UI with skill information (name, description, etc.) feature descriptions, available execution devices //foreach (var information in SkillHelper.SkillHelperMethods.GetSkillInformationStrings(m_skillDescriptor.Information)) //{ // UISkillInformation.Children.Add(new HeaderedContentControl() { Header = information.Key, Content = information.Value }); //} // Refresh UI with skill input feature descriptions foreach (var featureDesc in m_skillDescriptor.InputFeatureDescriptors) { foreach (var information in SkillHelper.SkillHelperMethods.GetSkillFeatureDescriptorStrings(featureDesc)) { UISkillInputDescription.Children.Add(new HeaderedContentControl() { Header = information.Key, Content = information.Value }); } } // Refresh UI with skill output feature descriptions foreach (var featureDesc in m_skillDescriptor.OutputFeatureDescriptors) { foreach (var information in SkillHelper.SkillHelperMethods.GetSkillFeatureDescriptorStrings(featureDesc)) { UISkillOutputDescription.Children.Add(new HeaderedContentControl() { Header = information.Key, Content = information.Value }); } } // Refresh UI with available execution devices on the system supported by the skill m_availableDevices = await m_skillDescriptor.GetSupportedExecutionDevicesAsync(); if (m_availableDevices.Count == 0) { await(new MessageDialog("No execution devices available, this skill cannot run on this device")).ShowAsync(); } else { // Display available execution devices and select the CPU UISkillExecutionDevices.ItemsSource = m_availableDevices.Select((device) => device.Name); int selectionIndex = 0; for (int i = 0; i < m_availableDevices.Count; i++) { if (m_availableDevices[i].ExecutionDeviceKind == SkillExecutionDeviceKind.Cpu) { selectionIndex = i; break; } } UISkillExecutionDevices.SelectedIndex = selectionIndex; // Alow user to interact with the app UIButtonFilePick.IsEnabled = true; UIButtonFilePick.Focus(FocusState.Keyboard); } }
/// <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_faceSentimentRenderer = new FaceSentimentRenderer(UICanvasOverlay, UISentiment); try { // Instatiate skill descriptor to display details about the skill and populate UI m_skillDescriptor = new FaceSentimentAnalyzerDescriptor(); m_availableExecutionDevices = await m_skillDescriptor.GetSupportedExecutionDevicesAsync(); // Show skill description members in UI UISkillName.Text = m_skillDescriptor.Name; UISkillDescription.Text = SkillHelper.SkillHelperMethods.GetSkillDescriptorString(m_skillDescriptor); int featureIndex = 0; foreach (var featureDesc in m_skillDescriptor.InputFeatureDescriptors) { UISkillInputDescription.Text += SkillHelper.SkillHelperMethods.GetSkillFeatureDescriptorString(featureDesc); if (featureIndex++ < m_skillDescriptor.InputFeatureDescriptors.Count - 1) { UISkillInputDescription.Text += "\n----\n"; } } featureIndex = 0; foreach (var featureDesc in m_skillDescriptor.OutputFeatureDescriptors) { UISkillOutputDescription.Text += SkillHelper.SkillHelperMethods.GetSkillFeatureDescriptorString(featureDesc); if (featureIndex++ < m_skillDescriptor.OutputFeatureDescriptors.Count - 1) { UISkillOutputDescription.Text += "\n----\n"; } } 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; }
/// <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_faceSentimentRenderer = new FaceSentimentRenderer(UICanvasOverlay, UISentiment); try { // Instatiate skill descriptor to display details about the skill and populate UI m_skillDescriptor = new FaceSentimentAnalyzerDescriptor(); m_availableExecutionDevices = await m_skillDescriptor.GetSupportedExecutionDevicesAsync(); // Show skill description members in UI UISkillName.Text = m_skillDescriptor.Name; UISkillDescription.Text = $"{m_skillDescriptor.Description}" + $"\n\tauthored by: {m_skillDescriptor.Version.Author}" + $"\n\tpublished by: {m_skillDescriptor.Version.Author}" + $"\n\tversion: {m_skillDescriptor.Version.Major}.{m_skillDescriptor.Version.Minor}" + $"\n\tunique ID: {m_skillDescriptor.Id}"; var inputDesc = m_skillDescriptor.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_skillDescriptor.OutputFeatureDescriptors[0] as SkillFeatureTensorDescriptor; UISkillOutputDescription1.Text = $"\tName: {outputDesc1.Name}, Description: {outputDesc1.Description} \n\tType: {outputDesc1.FeatureKind} of {outputDesc1.ElementKind} with shape [{outputDesc1.Shape.Select(i => i.ToString()).Aggregate((a, b) => a + ", " + b)}]"; var outputDesc2 = m_skillDescriptor.OutputFeatureDescriptors[1] as SkillFeatureTensorDescriptor; UISkillOutputDescription2.Text = $"\tName: {outputDesc2.Name} \n\tDescription: {outputDesc2.Description} \n\tType: {outputDesc2.FeatureKind} of {outputDesc2.ElementKind} with shape [{outputDesc2.Shape.Select(i => i.ToString()).Aggregate((a, b) => a + ", " + b)}]"; 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; }
/// <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; }
protected async override void OnNavigatedTo(NavigationEventArgs e) { Debug.WriteLine("OnNavigatedTo"); try { // Instatiate skill descriptor to display details about the skill and populate UI m_skillDescriptor = new NeuralStyleTransformerDescriptor(); m_availableExecutionDevices = await m_skillDescriptor.GetSupportedExecutionDevicesAsync(); // Show skill description members in UI UISkillName.Text = m_skillDescriptor.Name; UISkillDescription.Text = SkillHelper.SkillHelperMethods.GetSkillDescriptorString(m_skillDescriptor); int featureIndex = 0; foreach (var featureDesc in m_skillDescriptor.InputFeatureDescriptors) { UISkillInputDescription.Text += SkillHelper.SkillHelperMethods.GetSkillFeatureDescriptorString(featureDesc); if (featureIndex++ < m_skillDescriptor.InputFeatureDescriptors.Count - 1) { UISkillInputDescription.Text += "\n----\n"; } } featureIndex = 0; foreach (var featureDesc in m_skillDescriptor.OutputFeatureDescriptors) { UISkillOutputDescription.Text += SkillHelper.SkillHelperMethods.GetSkillFeatureDescriptorString(featureDesc); if (featureIndex++ < m_skillDescriptor.OutputFeatureDescriptors.Count - 1) { UISkillOutputDescription.Text += "\n----\n"; } } 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).ToList(); UISkillExecutionDevices.SelectedIndex = 0; // Alow user to interact with the app UIButtonFilePick.IsEnabled = true; UIButtonFilePick.Focus(FocusState.Keyboard); } } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } _resultframeRenderer = new FrameRenderer(UIResultImage); _inputFrameRenderer = new FrameRenderer(UIInputImage); UIStyleList.ItemsSource = _kModelFileNames; UIInkCanvasInput.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch; UIInkCanvasInput.InkPresenter.UpdateDefaultDrawingAttributes( new Windows.UI.Input.Inking.InkDrawingAttributes() { Color = Windows.UI.Colors.Black, Size = new Size(8, 8), IgnorePressure = true, IgnoreTilt = true, } ); // Select first style UIStyleList.SelectedIndex = 0; // Create a 1 second timer _FramesPerSecondTimer.Tick += _FramesPerSecond_Tick; _FramesPerSecondTimer.Interval = new TimeSpan(0, 0, 1); _FramesPerSecondTimer.Start(); }