Esempio n. 1
0
        void UseTextRecognitionModel()
        {
            VisionTextRecognizer textRecognizer;

            if (currentApiResource == ApiResource.OnDevice)
            {
                textRecognizer = vision.GetOnDeviceTextRecognizer();
            }
            else
            {
                // To provide language hints to assist with language detection:
                // See https://cloud.google.com/vision/docs/languages for supported languages
                var options = new VisionCloudTextRecognizerOptions {
                    LanguageHints = new [] { "es" }
                };
                textRecognizer = vision.GetCloudTextRecognizer(options);
            }

            var image = new VisionImage(ImgSample.Image);

            textRecognizer.ProcessImage(image, HandleVisionTextRecognitionCallback);

            void HandleVisionTextRecognitionCallback(VisionText text, NSError error)
            {
                TxtData.Text = error?.Description ?? text?.Text;
            }
        }