private async void OnRecognize()

in PlaneIdentifier/PlaneIdentifier.Desktop/MainWindow.xaml.cs [33:65]


        private async void OnRecognize(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            if (dialog.ShowDialog() == true)
            {
                string fileName = dialog.FileName;
                var selectedStorageFile = await StorageFile.GetFileFromPathAsync(dialog.FileName);

                SoftwareBitmap softwareBitmap;

                using (IRandomAccessStream stream = await selectedStorageFile.OpenAsync(FileAccessMode.Read))
                {
                    // Create the decoder from the stream 
                    Windows.Graphics.Imaging.BitmapDecoder decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);

                    // Get the SoftwareBitmap representation of the file in BGRA8 format
                    softwareBitmap = await decoder.GetSoftwareBitmapAsync();
                    softwareBitmap = SoftwareBitmap.Convert(softwareBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied);
                }

                // Display the image
                //SoftwareBitmapSource imageSource = new SoftwareBitmapSource();
                //await imageSource.SetBitmapAsync(softwareBitmap);

                //PreviewImage.Source = imageSource;

                PreviewImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(fileName));

                // Encapsulate the image in the WinML image type (VideoFrame) to be bound and evaluated
                VideoFrame inputImage = VideoFrame.CreateWithSoftwareBitmap(softwareBitmap);
                await EvaluateVideoFrameAsync(inputImage);
            }
        }