Exemple #1
0
        void UseLandmarkRecognitionModel()
        {
            var options = new VisionCloudDetectorOptions {
                ModelType  = VisionCloudModelType.Stable,
                MaxResults = 5
            };
            var landmarkDetector = vision.GetCloudLandmarkDetector(options);
            var image            = new VisionImage(ImgSample.Image);

            landmarkDetector.Detect(image, HandleVisionCloudLandmarkDetectionCallback);

            void HandleVisionCloudLandmarkDetectionCallback(VisionCloudLandmark [] landmarks, NSError error)
            {
                if (error != null)
                {
                    TxtData.Text = error.Description;
                    return;
                }

                if (landmarks == null || landmarks.Length == 0)
                {
                    TxtData.Text = "No landmarks were found.";
                    return;
                }

                var stringBuilder = new StringBuilder();

                foreach (var landmark in landmarks)
                {
                    stringBuilder.AppendLine($"Landmark: {landmark.Landmark}");
                    stringBuilder.AppendLine($"Entity Id: {landmark.EntityId}");
                    stringBuilder.AppendLine($"Confidence: {landmark.Confidence}");
                    stringBuilder.AppendLine();
                }

                TxtData.Text = stringBuilder.ToString();
            }
        }