private async void CameraHelper_FrameArrived(object sender, Microsoft.Toolkit.Uwp.Helpers.FrameEventArgs e) { if (e?.VideoFrame?.SoftwareBitmap == null) { return; } _stopwatch = Stopwatch.StartNew(); ImageFeatureValue _image = ImageFeatureValue.CreateFromVideoFrame(e.VideoFrame); var input = new Yolov2Input { image = _image }; var output = _model.EvaluateAsync(input).GetAwaiter().GetResult(); _stopwatch.Stop(); IReadOnlyList <float> vectorImage = output.grid.GetAsVectorView(); IList <float> imageList = vectorImage.ToList(); _boxes = _parser.ParseOutputs(vectorImage.ToArray()); var maxIndex = imageList.IndexOf(imageList.Max()); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { TextBlockInformation.Text = $"{1000f / _stopwatch.ElapsedMilliseconds,4:f1} fps on Width {_cameraModel.Width} x Height {_cameraModel}"; DrawOverlays(e.VideoFrame); }); }
public async Task <Yolov2Output> EvaluateAsync(Yolov2Input input) { Binding.Bind("image", input.image); var result = await Session.EvaluateAsync(Binding, "0"); var output = new Yolov2Output { grid = result.Outputs["grid"] as TensorFloat }; return(output); }