コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: hernandoz/VisionAI
        async Task PredictPhoto(MediaFile photo)
        {
            var endpoint = new PredictionEndpoint
            {
                ApiKey = await KeyService.GetPredictionKey()
            };

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

            AllPredictions = results.Predictions
                             .Where(p => p.Probability > Probability)
                             .ToList();


            // Create the Api, passing in the training key
            CustomVisionTrainingClient trainingApi = new CustomVisionTrainingClient()
            {
                ApiKey   = KeyService.TK,
                Endpoint = KeyService.SouthCentralUsEndpoint
            };

            // Find the object detection domain

            //var domains = trainingApi.GetDomains();
            //var objDetectionDomain = domains.FirstOrDefault(d => d.Type == "ObjectDetection");

            //upload to service
            trainingApi.CreateImagesFromData(Guid.Parse(await KeyService.GetProjectId()), photo.GetStream(), null);
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: nomada2/ObjectDetector
 protected override async void OnStart()
 {
     if (string.IsNullOrWhiteSpace(await KeyService.GetPredictionKey()) ||
         string.IsNullOrWhiteSpace(await KeyService.GetProjectId()))
     {
         await MainPage.Navigation.PushModalAsync(SettingsPage.CreateSettingsPage(), false);
     }
 }
コード例 #3
0
        public async Task SetUp()
        {
            try
            {
                PredictionKey = await KeyService.GetPredictionKey();

                ProjectId = await KeyService.GetProjectId();
            }
            finally
            {
                IsEnabled = true;
            }
        }
コード例 #4
0
        async Task PredictPhoto(MediaFile photo)
        {
            var endpoint = new PredictionEndpoint
            {
                ApiKey = await KeyService.GetPredictionKey()
            };

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

            AllPredictions = results.Predictions
                             .Where(p => p.Probability > Probability)
                             .ToList();
        }
コード例 #5
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();
        }
コード例 #6
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;
                }
            }
        }
コード例 #7
0
        public SettingsViewModel()
        {
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
            OpenCustomVisionCommand = new Command(async() => await Xamarin.Essentials.Launcher.OpenAsync("https://customvision.ai"));
            OkCommand = new Command(async() => await Ok(), () => !string.IsNullOrWhiteSpace(PredictionKey) && !string.IsNullOrWhiteSpace(ProjectId) && Guid.TryParse(ProjectId, out var g));
            ConfigureCanCancelCommand = new Command(async() => CanCancel = !string.IsNullOrWhiteSpace(await KeyService.GetPredictionKey()) && !string.IsNullOrWhiteSpace(await KeyService.GetProjectId()));
            CancelCommand             = new Command(async() => await Application.Current.MainPage.Navigation.PopModalAsync());
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void

            IsEnabled = false;
        }