Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async void UplodatePictureButton_Clicked(object sender, EventArgs e)
- {
- await CrossMedia.Current.Initialize();
- MediaFile file;
- if (!CrossMedia.Current.IsPickPhotoSupported)
- {
- await DisplayAlert("No upload", "Picking a photo is not supported", "OK");
- return;
- }
- file = await CrossMedia.Current.PickPhotoAsync();
- if (file == null)
- {
- return;
- }
- MainImage.Source = ImageSource.FromStream(() =>
- {
- var stream = file.GetStream();
- return stream;
- });
- // Create the Api, passing in the training key
- CustomVisionTrainingClient trainingApi = new CustomVisionTrainingClient()
- {
- ApiKey = trainingKey,
- Endpoint = SouthCentralUsEndpointTraining
- };
- var projects = trainingApi.GetProjects();
- var project = projects.FirstOrDefault(p => p.Name == "Car");
- CustomVisionPredictionClient endpoint = new CustomVisionPredictionClient()
- {
- ApiKey = predictionKey,
- Endpoint = SouthCentralUsEndpointPrediction
- };
- var result = endpoint.ClassifyImageUrl(project.Id, project.Name, new Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.Models.ImageUrl(file.Path));
- foreach (var c in result.Predictions)
- {
- Console.WriteLine($"t{c.TagName}: {c.Probability:P1}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement