public async Task <IList <YoloBoundingBox> > AnalyzeImage(VideoFrame videoFrame) { // This appears to be the right way to handle background tasks. // We return to the main thread as fast as we can, and wait for the next call to the Update() // to advance our processing #if SDK_1809 TinyYoloV2O12Input input = new TinyYoloV2O12Input { image = ImageFeatureValue.CreateFromVideoFrame(videoFrame) }; #else TinyYoloV2O1ModelInput input = new TinyYoloV2O1ModelInput { image = videoFrame }; #endif var dims = GetDimensionsFromVideoFrame(videoFrame); int width = dims.Item1; int height = dims.Item2; var predictions = await model.EvaluateAsync(input).ConfigureAwait(false); #if SDK_1809 var boxes = parser.ParseOutputs(predictions.grid.GetAsVectorView().ToArray(), width, height, DetectionThreshold); #else var boxes = parser.ParseOutputs(predictions.grid.ToArray(), width, height, DetectionThreshold); #endif boxes = boxes.Where(b => b.Confidence >= DetectionThreshold).ToList(); // normalize coordinates boxes = parser.NonMaxSuppress(boxes); return(boxes.ToList()); }
public async Task <TinyYoloV2O12Output> EvaluateAsync(TinyYoloV2O12Input input) { binding.Bind("image", input.image); var result = await session.EvaluateAsync(binding, "0"); var output = new TinyYoloV2O12Output(); output.grid = result.Outputs["grid"] as TensorFloat; return(output); }