Ejemplo n.º 1
0
        private async Task <OnnxModelOutput> EvaluateVideoFrameAsync(VideoFrame frame)
        {
            if (frame != null)
            {
                try
                {
                    OnnxModelInput inputData = new OnnxModelInput();
                    inputData.data = frame;
                    var results = await _model.EvaluateAsync(inputData);

                    _misty.SendDebugMessage("Boxes: " + string.Join(", ", results.detected_boxes.GetAsVectorView()) + " Classes: " + string.Join(", ", results.detected_classes.GetAsVectorView()) + " Scores: " + string.Join(", ", results.detected_scores.GetAsVectorView()), null);

                    return(results);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"error: {ex.Message}");
                    _misty.SendDebugMessage($"error: {ex.Message}", null);

                    return(null);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private async Task <OnnxModelOutput> EvaluateAsyncHelper(OnnxModelInput input)
        {
            binding.Bind("image_tensor", input.data);
            var result = await session.EvaluateAsync(binding, string.Empty);

            OnnxModelOutput output = new OnnxModelOutput();

            output.detected_boxes   = result.Outputs["detected_boxes"] as TensorFloat;
            output.detected_classes = result.Outputs["detected_classes"] as TensorInt64Bit;
            output.detected_scores  = result.Outputs["detected_scores"] as TensorFloat;

            return(output);
        }
Ejemplo n.º 3
0
 public IAsyncOperation <OnnxModelOutput> EvaluateAsync(OnnxModelInput input)
 {
     return(this.EvaluateAsyncHelper(input).AsAsyncOperation());
 }