private void CleanupInputImage()
 {
     try
     {
         if (InputSoftwareBitmapSource != null)
         {
             InputSoftwareBitmapSource.Dispose();
             InputSoftwareBitmapSource = new SoftwareBitmapSource();
         }
         if (OutputSoftwareBitmapSource != null)
         {
             OutputSoftwareBitmapSource.Dispose();
             OutputSoftwareBitmapSource = new SoftwareBitmapSource();
         }
         if (_appModel.OutputFrame != null)
         {
             _appModel.OutputFrame.Dispose();
         }
         _appModel.OutputFrame = new VideoFrame(BitmapPixelFormat.Bgra8, (int)_outWidth, (int)_outHeight);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
        private async Task EvaluateVideoFrameAsync()
        {
            Debug.WriteLine("EvaluateVideoFrameAsync");
            if (_appModel.InputFrame.Direct3DSurface != null)
            {
                Debug.WriteLine("Has Direct3dsurface");
            }
            if ((_appModel.InputFrame != null) &&
                (_appModel.InputFrame.SoftwareBitmap != null || _appModel.InputFrame.Direct3DSurface != null))
            {
                _appModel.InputFrame = await ImageHelper.CenterCropImageAsync(_appModel.InputFrame, _inWidth, _inHeight);

                await InputSoftwareBitmapSource.SetBitmapAsync(_appModel.InputFrame.SoftwareBitmap);

                // Lock so eval + binding not destroyed mid-evaluation
                Debug.Write("Eval Begin | ");
                LearningModelEvaluationResult results;
                lock (_processLock)
                {
                    Debug.Write("Eval Lock | ");
                    _binding.Bind(_inputImageDescription, ImageFeatureValue.CreateFromVideoFrame(_appModel.InputFrame));
                    _binding.Bind(_outputImageDescription, ImageFeatureValue.CreateFromVideoFrame(_appModel.OutputFrame));
                    results = _session.Evaluate(_binding, "test");
                }
                Debug.Write("Eval Unlock\n");

                // Parse Results
                IReadOnlyDictionary <string, object> outputs = results.Outputs;
                foreach (var output in outputs)
                {
                    Debug.WriteLine($"{output.Key} : {output.Value} -> {output.Value.GetType()}");
                }

                await OutputSoftwareBitmapSource.SetBitmapAsync(_appModel.OutputFrame.SoftwareBitmap);
            }
        }