コード例 #1
0
        public async Task <SingelObjectApeModelV8Output> EvaluateAsync(SingelObjectApeModelV8Input input)
        {
            var output = new SingelObjectApeModelV8Output();

            if (input != null)
            {
                binding.Bind("image", input.Image);
                var result = await session.EvaluateAsync(binding, "0");

                output.Grid = result.Outputs["grid"] as TensorFloat;
            }

            return(output);
        }
コード例 #2
0
        public async Task <List <CubicBoundingBox> > DetectObjectPoseFromImagePixelsAsync(byte[] imagePixels)
        {
            List <CubicBoundingBox> boxes = new List <CubicBoundingBox>();

            using (var imageTensor = ConvertPixelsByteToTensor(imagePixels, BitmapPixelFormat.Bgra8))
                using (var input = new SingelObjectApeModelV8Input()
                {
                    Image = imageTensor
                })
                    using (var output = await model.EvaluateAsync(input).ConfigureAwait(true))
                    {
                        var            shape   = output.Grid.Shape;
                        var            content = output.Grid.GetAsVectorView().ToArray();
                        List <float[]> abc     = new List <float[]>
                        {
                            content
                        };

                        using (OutputParser outputParser = new OutputParser(abc, classCount, anchorCount, confThresh))
                        {
                            foreach (var box in outputParser.BoundingBoxes)
                            {
                                var newBox = new CubicBoundingBox()
                                {
                                    Confidence = box.Confidence,
                                    Identity   = box.Identity
                                };
                                foreach (var point in box.ControlPoint)
                                {
                                    newBox.ControlPoint.Append(point);
                                }
                                boxes.Add(box);
                            }
                        }
                    }



            return(boxes);
        }
コード例 #3
0
        private async void DetectObjectPoseFromPicFile(StorageFile inputFile)
        {
            openedFile = inputFile;
            var file = inputFile;

            //var transform = new BitmapTransform() { ScaledWidth = 416, ScaledHeight = 416, InterpolationMode = BitmapInterpolationMode.Fant };

            using (var stream = await file.OpenAsync(FileAccessMode.Read))
            {
                BitmapSource bitmapSource = new BitmapImage();
                bitmapSource.SetSource(stream);
                InputImage.Source = bitmapSource;

                BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);

                using (var imageTensor = await ConvertImageToTensorAsync(decoder).ConfigureAwait(true))
                    using (var input = new SingelObjectApeModelV8Input()
                    {
                        Image = imageTensor
                    })
                        using (var output = await model.EvaluateAsync(input).ConfigureAwait(true))
                        {
                            var            shape     = output.Grid.Shape;
                            var            content   = output.Grid.GetAsVectorView().ToArray();
                            List <float[]> rawOutput = new List <float[]>
                            {
                                content
                            };
                            using (OutputParser outputParser = new OutputParser(rawOutput, classCount, anchorCount, confThresh))
                            {
                                var boxes = outputParser.BoundingBoxes;
                                DrawBoxes(stream, boxes);
                            }
                        }
            }
        }