/// <summary> /// Run a complete detection on a new image. /// </summary> private void RunDetection() { // clear the label Description.Text = "---"; // show the spinner Spinner.Visibility = Visibility.Visible; // detect what's in the image (var cat, var dog) = DetectScene(imagePath); // build the description var description = cat > dog ? "Cat" : "Dog"; description += $" detected - cat confidence: {cat * 100:0}%"; description += $", dog confidence: {dog * 100:0}%"; // show the description Description.Text = description; // hide the spinner Spinner.Visibility = Visibility.Hidden; // tell the canvas to redraw itself MainCanvas.InvalidateVisual(); }
/// <summary> /// Run a complete face detection on a new image. /// </summary> private async Task RunFaceDetection() { // show the spinner Spinner.Visibility = Visibility.Visible; // clear any existing face rectangles and labels var toDelete = new List <UIElement>(); foreach (var element in MainCanvas.Children.OfType <UIElement>()) { if (element is System.Windows.Shapes.Rectangle || element is Label) { toDelete.Add(element); } } foreach (var element in toDelete) { MainCanvas.Children.Remove(element); } // detect all faces in image celebrities = await DetectCelebrities(image); // draw face rectangles on the canvas foreach (var celebrity in celebrities) { DrawFaceRectangle(celebrity); } // hide the spinner Spinner.Visibility = Visibility.Hidden; // tell the canvas to redraw itself MainCanvas.InvalidateVisual(); }
/// <summary> /// Run a complete face detection on a new image. /// </summary> private async Task RunFaceDetection() { // show the spinner Spinner.Visibility = Visibility.Visible; // clear any existing face rectangles var toDelete = new List <UIElement>(MainCanvas.Children.OfType <System.Windows.Shapes.Rectangle>()); foreach (var element in toDelete) { MainCanvas.Children.Remove(element); } // detect all faces in image faces = await DetectFaces(image); // draw face rectangles on the canvas foreach (var face in faces) { DrawFaceRectangle(face); } // hide the spinner Spinner.Visibility = Visibility.Hidden; // tell the canvas to redraw itself MainCanvas.InvalidateVisual(); }
//Zoom private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (isRendered) { ScaleTransform scale; if (e.NewValue > e.OldValue) { scale = new ScaleTransform(MainCanvas.LayoutTransform.Value.M11 + 0.13, MainCanvas.LayoutTransform.Value.M22 + 0.13); } else { scale = new ScaleTransform(MainCanvas.LayoutTransform.Value.M11 - 0.13, MainCanvas.LayoutTransform.Value.M22 - 0.13); } MainCanvas.LayoutTransform = scale; MainCanvas.InvalidateVisual(); } }
public void EndPreview() { if (_shouldPlayMusic) { StopMusic(); } IsPreviewing = false; _hitsoundHandle.Set(); // ensure responding to dimension change _loaded = false; // clear canvas MainCanvas.Stop(); MainCanvas.InvalidateVisual(); }
/// <summary> /// Run a complete detection on a new image. /// </summary> private async Task RunDetection() { // show the spinner Spinner.Visibility = Visibility.Visible; // detect what's in the image description = await DetectScene(image); // show the description Description.Text = description; // hide the spinner Spinner.Visibility = Visibility.Hidden; // tell the canvas to redraw itself MainCanvas.InvalidateVisual(); // speak the description await SpeakDescription(description); }
/// <summary> /// Find the requested image and show it. /// </summary> /// <param name="searchString">The string to search for.</param> private async Task FindImage(string searchString) { // show the spinner Spinner.Visibility = Visibility.Visible; // find an image matching the query var img = await SearchForImage(searchString); if (img != null) { //// describe the image var description = await DescribeScene(img.ContentUrl); // show the image var image = new BitmapImage(new Uri(img.ContentUrl)); var brush = new ImageBrush(image); brush.Stretch = Stretch.Uniform; brush.AlignmentX = AlignmentX.Left; brush.AlignmentY = AlignmentY.Top; MainCanvas.Background = brush; // hide the spinner Spinner.Visibility = Visibility.Hidden; // tell the canvas to redraw itself MainCanvas.InvalidateVisual(); //// speak the description await SpeakDescription(description); } // hide the spinner else { Spinner.Visibility = Visibility.Hidden; } }