示例#1
0
        public async Task <TinyYoloV3Output> EvaluateAsync(TinyYoloV3Input input)
        {
            TinyYoloV3Output            output  = new TinyYoloV3Output();
            LearningModelBindingPreview binding = new LearningModelBindingPreview(_learningModel);

            binding.Bind("image", input.Image);
            binding.Bind("grid", output.Grid);
            LearningModelEvaluationResultPreview evalResult = await _learningModel.EvaluateAsync(binding, string.Empty);

            return(output);
        }
        private async void CameraHelper_FrameArrived(object sender, Microsoft.Toolkit.Uwp.Helpers.FrameEventArgs e)
        {
            if (e?.VideoFrame?.SoftwareBitmap == null)
            {
                return;
            }

            var input = new TinyYoloV3Input {
                Image = e.VideoFrame
            };

            _stopwatch = Stopwatch.StartNew();
            var output = await _model.EvaluateAsync(input);

            _stopwatch.Stop();
            _boxes = _parser.ParseOutputs(output.Grid.ToArray());

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                TextBlockInformation.Text = $"{1000f / _stopwatch.ElapsedMilliseconds,4:f1} FPS on Width {_yoloCanvasActualWidth} x Height {_yoloCanvasActualHeight}";
                DrawOverlays(e.VideoFrame);
            });
        }