Ejemplo n.º 1
0
        async Task PredictPhoto(MediaFile photo)
        {
            var endpoint = new CustomVisionPredictionClient
            {
                ApiKey   = await KeyService.GetPredictionKey(),
                Endpoint = await KeyService.GetEndpoint()
            };

            var results = await endpoint.DetectImageAsync(Guid.Parse(await KeyService.GetProjectId()),
                                                          await KeyService.GetPublishName(),
                                                          photo.GetStream());

            AllPredictions = results.Predictions
                             .Where(p => p.Probability > Probability)
                             .ToList();
        }
Ejemplo n.º 2
0
        public async Task SetUp()
        {
            if (string.IsNullOrWhiteSpace(PredictionKey) &&
                string.IsNullOrWhiteSpace(ProjectId) &&
                string.IsNullOrWhiteSpace(PublishName) &&
                string.IsNullOrWhiteSpace(Endpoint))
            {
                try
                {
                    PredictionKey = await KeyService.GetPredictionKey();

                    ProjectId = await KeyService.GetProjectId();

                    PublishName = await KeyService.GetPublishName();

                    Endpoint = await KeyService.GetEndpoint();
                }
                finally
                {
                    IsEnabled = true;
                }
            }
        }