private void startCameraSource() { try { textRecognizer = new TextRecognizer.Builder(this).Build(); if (!textRecognizer.IsOperational) { System.Diagnostics.Debug.WriteLine("Detector dependencies not loaded yet"); } else { mCameraSource = new CameraSource.Builder(this, textRecognizer) .SetFacing(CameraFacing.Back) .SetRequestedPreviewSize(1280, 1024) .SetAutoFocusEnabled(true) .SetRequestedFps(2.0f) .Build(); mCameraView.Holder.AddCallback(this); textRecognizer.SetProcessor(this); if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == Android.Content.PM.Permission.Granted) { mCameraSource.Start(mCameraView.Holder); } else { ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.Camera }, requestPermissionID); } } } catch (Exception ex) { } }
static void Main(string[] args) { string inputDocument = @".\areas-sample.pdf"; int pageIndex = 0; string outputDocument = @".\result.txt"; // Create and activate TextRecognizer instance using (TextRecognizer textRecognizer = new TextRecognizer("demo", "demo")) { try { // Load document (image or PDF) textRecognizer.LoadDocument(inputDocument); // Set location of "tessdata" folder containing language data files textRecognizer.OCRLanguageDataFolder = @"c:\Program Files\ByteScout Text Recognition SDK\tessdata\"; // Set OCR language. // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish etc - according to files in "tessdata" folder // Find more language files at https://github.com/tesseract-ocr/tessdata/tree/3.04.00 textRecognizer.OCRLanguage = "eng"; // Get page size (in pixels). Size of PDF document is computed from PDF Points // and the rendering resolution specified by `textRecognizer.PDFRenderingResolution` (default 300 DPI) Size pageSize = textRecognizer.GetPageSize(pageIndex); // Add area of interest as a rectangle at the top-right corner of the page textRecognizer.RecognitionAreas.Add(pageSize.Width / 2, 0, pageSize.Width / 2, 300); // Add area of interest as a rectangle at the bottom-left corner of the page, // and indicate it should be rotated at 90 deg textRecognizer.RecognitionAreas.Add(0, pageSize.Height / 2, 300, pageSize.Height / 2, AreaRotation.Rotate90FlipNone); // Now, you can get recognized text for further analysis as a list of objects // containing coordinates, object kind, confidence. OCRObjectList ocrObjectList = textRecognizer.GetOCRObjects(pageIndex); foreach (OCRObject ocrObject in ocrObjectList) { Console.WriteLine(ocrObject.ToString()); } // ... or you can save recognized text pieces to file textRecognizer.KeepTextFormatting = false; // save without formatting textRecognizer.SaveText(outputDocument, pageIndex, pageIndex); // Open the result file in default associated application (for demo purposes) Process.Start(outputDocument); } catch (Exception exception) { Console.WriteLine(exception); } } Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); }
public ImageRecognizer(Context context, Activity activity) { this.activity = activity; this.context = context; textRecognizer = new TextRecognizer.Builder(context).Build(); shopLensVoiceRec = new ShopLensSpeechRecognizer(OnVoiceRecResults); sltts = new ShopLensTextToSpeech(context, OnTextToSpeechInit, OnTextToSpeechEndOfSpeech); tts = new TextToSpeech(context, sltts); }
public override void Init() { if (Initialized) { return; } _initialized = true; TextRecognizer = new TextRecognizer.Builder(Android.App.Application.Context).Build(); BarcodeDetector = new BarcodeDetector.Builder(Android.App.Application.Context).SetBarcodeFormats(BarcodeFormat.QrCode).Build(); }
public void Run() { ByteBuffer buffer = mImage.GetPlanes()[0].Buffer; byte[] bytes = new byte[buffer.Remaining()]; buffer.Get(bytes); Bitmap bitmapImage = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length, null); textRecognizer = new TextRecognizer.Builder(context).Build(); imageRecognizer.RecognizeImage(bitmapImage, activity, owner); }
public bool Initialize(Stream modelData, bool useNumThreads) { using (var builder = new TextRecognizer.Builder(MainActivity.context)) { txtRecognizer = builder.Build(); } using (var ms = new MemoryStream()) { modelData.CopyTo(ms); model = new FlatBufferModel(ms.ToArray()); } if (!model.CheckModelIdentifier()) { return(false); } var op = new BuildinOpResolver(); interpreter = new Interpreter(model, op); if (useNumThreads) { interpreter.SetNumThreads(Environment.ProcessorCount); } var allocateTensorStatus = interpreter.AllocateTensors(); if (allocateTensorStatus == Status.Error) { return(false); } var input = interpreter.GetInput(); inputTensor = interpreter.GetTensor(input[0]); var output = interpreter.GetOutput(); var outputIndex = output[0]; outputTensors = new Tensor[output.Length]; for (var i = 0; i < output.Length; i++) { outputTensors[i] = interpreter.GetTensor(outputIndex + i); } return(true); }
/// <summary> /// Construct a sketch modification producer in the circuit domain using the given classifier and recognizer. /// It finds the circuit domain using CircuitDomain.GetInstance(). /// </summary> public CircuitSketchModificationProducer( Classifier classifier, ExtendedRecognizer gateRecognizer, Connector connector, TextRecognizer textRecognizer = null, Recognizer wireRecognizer = null) { _domain = CircuitDomain.GetInstance(); _classifier = classifier; _gateRecognizer = gateRecognizer; _textRecognizer = (textRecognizer == null) ? new TextRecognizer() : textRecognizer; _wireRecognizer = (wireRecognizer == null) ? new WireRecognizer() : wireRecognizer; _connector = connector; // caches are initialized in Start(FeatureSketch) }
private void RecognizeHandler() { DateTime dNow = DateTime.Now; var container = _eulerContainersCache[SelectedLanguage]; TextRecognizer recognizer = new TextRecognizer(container); var report = recognizer.Recognize(_sourceBitmap); // Выводим RecognitionTime = (DateTime.Now - dNow).ToString(); RecognitionResult = report.RawText(); // визуализируем найденные итоги var visualizedImage = new Bitmap(_sourceBitmap); RecognitionVisualizerUtils.Visualize(visualizedImage, report); SourceImage = visualizedImage.ToBitmapSource(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); Button button = (Button)FindViewById(Resource.Id.button); scanResults = (TextView)FindViewById(Resource.Id.results); if (savedInstanceState != null) { imageUri = Android.Net.Uri.Parse(savedInstanceState.GetString(SAVED_INSTANCE_URI)); scanResults.Text = savedInstanceState.GetString(SAVED_INSTANCE_RESULT); } detector = new TextRecognizer.Builder(ApplicationContext).Build(); button.SetOnClickListener(this); }
static void Main(string[] args) { string inputDocument = @".\bad-quality.png"; string outputDocument = @".\result.txt"; // Create and activate TextRecognizer instance using (TextRecognizer textRecognizer = new TextRecognizer("demo", "demo")) { try { // Load document (image or PDF) textRecognizer.LoadDocument(inputDocument); // Set the location of OCR language data files textRecognizer.OCRLanguageDataFolder = @"c:\Program Files\ByteScout Text Recognition SDK\ocrdata_fast\"; // Set OCR language. // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish, etc. - according to files in "ocrdata" folder // Find more language files at https://github.com/bytescout/ocrdata textRecognizer.OCRLanguage = "eng"; // Add error corrections that will be applied after the recognition. textRecognizer.Corrections.Add("Tut ", "Test "); textRecognizer.Corrections.Add("Recog\\w{1,}on", "Recognition", true); // Recognize text from all pages and save it to file textRecognizer.SaveText(outputDocument); // Open the result file in default associated application (for demo purposes) Process.Start(outputDocument); } catch (Exception exception) { Console.WriteLine(exception); } } Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); }
public void CrearTextRecognizer() { textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build(); if (!textRecognizer.IsOperational) { Log.Error("Aviso:", "Detector no disponible!"); } else { // Caracteristicas del CameraSource cameraSource = new CameraSource.Builder(ApplicationContext, textRecognizer) .SetFacing(CameraFacing.Back) //Camara seleccionada .SetRequestedPreviewSize(1920, 1080) //Tamaño de la vista previa en uso por la camara .SetRequestedFps(2.0f) //Velocidad de fotogramas (En fotogramas por segundo) .SetAutoFocusEnabled(true) //Autoenfoque .Build(); cameraView.Holder.AddCallback(this); //Recibe informacion del SurfaceView. textRecognizer.SetProcessor(this); //Estable Iprocessor para el textRecognizer. } }
private void Analyze() { //var dic = GetEulerContainer(@"..\..\..\Qocr.Dics\RU-ru.bin"); var dic = GetEulerContainer(@"..\..\Qocr.Dics\EN-en.bin"); DateTime nowInit = DateTime.Now; // ИСПОЛЬЗУЙ Gen.bin _recognizer = _recognizer ?? new TextRecognizer(dic); DateTime nowRecognition = DateTime.Now; var bitmap = BitmapUtils.BitmapFromSource((BitmapSource)ApproximatedImage); var report = _recognizer.Recognize(bitmap); MessageBox.Show( $"Init time: {nowRecognition - nowInit}\n\rRecognition time: {DateTime.Now - nowRecognition}"); RecognitionVisualizerUtils.Visualize(bitmap, report); ApproximatedImage = BitmapUtils.SourceFromBitmap(bitmap); }
static void Main(string[] args) { string outputDocument = @".\result.txt"; // Create and activate TextRecognizer instance using (TextRecognizer textRecognizer = new TextRecognizer("demo", "demo")) { try { // Create ScreenshotMaker instance ScreenshotMaker screenshotMaker = new ScreenshotMaker(); // Set rectangle to take screenshot from screenshotMaker.SetScreenshotArea(0, 0, 200, 200); // Load screenshot textRecognizer.LoadDocument(screenshotMaker); // Set the location of OCR language data files textRecognizer.OCRLanguageDataFolder = @"c:\Program Files\ByteScout Text Recognition SDK\ocrdata_best\"; // Set OCR language. // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish, etc. - according to files in "ocrdata" folder // Find more language files at https://github.com/bytescout/ocrdata textRecognizer.OCRLanguage = "eng"; // Recognize text from all pages and save it to file textRecognizer.SaveText(outputDocument); // Open the result file in default associated application (for demo purposes) Process.Start(outputDocument); } catch (Exception exception) { Console.WriteLine(exception); } } Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); }
static void Main(string[] args) { string inputUrl = @"https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/image-to-pdf/image1.png"; string outputDocument = @".\result.txt"; // Get stream from input url var inputStream = GetStreamFromUrl(inputUrl); // Create and activate TextRecognizer instance using (TextRecognizer textRecognizer = new TextRecognizer("demo", "demo")) { try { // Load document (image or PDF) textRecognizer.LoadDocument(inputStream); // Set the location of OCR language data files textRecognizer.OCRLanguageDataFolder = @"C:\Program Files\ByteScout Text Recognition SDK\ocrdata_best\"; // Set OCR language. // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish, etc. - according to files in "ocrdata" folder // Find more language files at https://github.com/bytescout/ocrdata textRecognizer.OCRLanguage = "eng"; // Recognize text from all pages and save it to file textRecognizer.SaveText(outputDocument); // Open the result file in default associated application (for demo purposes) Process.Start(outputDocument); } catch (Exception exception) { Console.WriteLine(exception); } } Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); }
private void BtnGetTextOnClick(object sender, EventArgs e) { txtRecognizer = new TextRecognizer.Builder(ApplicationContext).Build(); if (!txtRecognizer.IsOperational) { txt_text.Text = "Error"; } else { Frame fr = new Frame.Builder().SetBitmap(bitmap1).Build(); SparseArray items = txtRecognizer.Detect(fr); StringBuilder stBuilder = new StringBuilder(); for (int i = 0; i < items.Size(); i++) { TextBlock item = (TextBlock)items.ValueAt(i); stBuilder.Append(item.Value); stBuilder.Append("\n"); } txt_text.Text = stBuilder.ToString(); } }
static void Main(string[] args) { string inputDocument = @".\ocr-sample.pdf"; string outputDocument = @".\result.json"; // Create and activate TextRecognizer instance using (TextRecognizer textRecognizer = new TextRecognizer("demo", "demo")) { try { // Load document (image or PDF) textRecognizer.LoadDocument(inputDocument); // Set the location of OCR language data files textRecognizer.OCRLanguageDataFolder = @"c:\Program Files\ByteScout Text Recognition SDK\ocrdata_best\"; // Set OCR language. // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish, etc. - according to files in "ocrdata" folder // Find more language files at https://github.com/bytescout/ocrdata textRecognizer.OCRLanguage = "eng"; // Recognize text from page and save each ocr word object to json textRecognizer.SaveOCRObjectsAsJSON(outputDocument, 0, OCRObjectType.Word); // Open the result file in default associated application (for demo purposes) Process.Start(outputDocument); } catch (Exception exception) { Console.WriteLine(exception); } } Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); }
static void Main(string[] args) { string inputDocument = @".\invoice-sample.png"; string outputDocument = @".\result.txt"; // Create and activate TextRecognizer instance using (TextRecognizer textRecognizer = new TextRecognizer("demo", "demo")) { try { // Load document (image or PDF) textRecognizer.LoadDocument(inputDocument); // Set location of "tessdata" folder containing language data files textRecognizer.OCRLanguageDataFolder = @"c:\Program Files\ByteScout Text Recognition SDK\tessdata\"; // Set OCR language. // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish etc - according to files in "tessdata" folder // Find more language files at https://github.com/tesseract-ocr/tessdata/tree/3.04.00 textRecognizer.OCRLanguage = "eng"; // Recognize text from all pages and save it to file textRecognizer.SaveText(outputDocument); // Open the result file in default associated application (for demo purposes) Process.Start(outputDocument); } catch (Exception exception) { Console.WriteLine(exception); } } Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); imgView = FindViewById <ImageView>(Resource.Id.imgView); txt = FindViewById <TextView>(Resource.Id.txtView); btn = FindViewById <Button>(Resource.Id.btn); btnCamera = FindViewById <Button>(Resource.Id.btnFoto); btnCamera.Click += Btn_Click; textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build(); btn.Click += Ler; btnGo = FindViewById <Button>(Resource.Id.btnGo); btnGo.Click += delegate { var intent = new Intent(this, typeof(Leitura)); StartActivity(intent); }; }
static void Main(string[] args) { string inputDocument = @".\skewed.png"; string outputDocument = @".\result.txt"; // Create and activate TextRecognizer instance using (TextRecognizer textRecognizer = new TextRecognizer("demo", "demo")) { try { // Load document (image or PDF) textRecognizer.LoadDocument(inputDocument); // Set the location of OCR language data files textRecognizer.OCRLanguageDataFolder = @"c:\Program Files\ByteScout Text Recognition SDK\ocrdata_best\"; // Set OCR language. // "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish, etc. - according to files in "ocrdata" folder // Find more language files at https://github.com/bytescout/ocrdata textRecognizer.OCRLanguage = "eng"; // Add deskew filter that automatically rotates the image to make the text horizontal. // Note, it analyzes the left edge of scanned text. Any dark artifacts may prevent // the correct angle detection. textRecognizer.ImagePreprocessingFilters.AddDeskew(); // Other filters that may be useful to improve recognition // (note, the filters are applied in the order they were added): // Improve image contrast. //textRecognizer.ImagePreprocessingFilters.AddContrast(); // Apply gamma correction. //textRecognizer.ImagePreprocessingFilters.AddGammaCorrection(); // Apply median filter. Helps to remove noise. //textRecognizer.ImagePreprocessingFilters.AddMedian(); // Apply dilate filter. Helps to cure symbols erosion. //textRecognizer.ImagePreprocessingFilters.AddDilate(); // Lines removers. Removing borders of some tables may improve the recognition. //textRecognizer.ImagePreprocessingFilters.AddHorizontalLinesRemover(); //textRecognizer.ImagePreprocessingFilters.AddVerticalLinesRemover(); // Recognize text from all pages and save it to file textRecognizer.SaveText(outputDocument); // Open the result file in default associated application (for demo purposes) Process.Start(outputDocument); } catch (Exception exception) { Console.WriteLine(exception); } } // Console.WriteLine(); // Console.WriteLine("Press any key..."); // Console.ReadKey(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); surfaceView = FindViewById <SurfaceView>(Resource.Id.surface_view); textView = FindViewById <TextView>(Resource.Id.txt_view); capture = FindViewById <ImageView>(Resource.Id.imageView2); mainLayout = FindViewById <LinearLayout>(Resource.Id.mainmenulayout); captureLayout = FindViewById <LinearLayout>(Resource.Id.capturemenulayout); back = FindViewById <ImageView>(Resource.Id.imageView4); speak = FindViewById <ImageView>(Resource.Id.imageView5); translate = FindViewById <ImageView>(Resource.Id.imageView6); settings = FindViewById <ImageView>(Resource.Id.imageView3); gallery = FindViewById <ImageView>(Resource.Id.imageView1); selectedimage = FindViewById <ImageView>(Resource.Id.imageView7); capture.Click += (sender, e) => { cameraSource.Stop(); mainLayout.Visibility = ViewStates.Gone; captureLayout.Visibility = ViewStates.Visible; textView.FocusableInTouchMode = true; }; back.Click += (sender, e) => { captureLayout.Visibility = ViewStates.Gone; selectedimage.Visibility = ViewStates.Gone; mainLayout.Visibility = ViewStates.Visible; surfaceView.Visibility = ViewStates.Visible; cameraSource.Start(surfaceView.Holder); }; gallery.Click += (sender, e) => { cameraSource.Stop(); Intent galleryIntent = new Intent(); galleryIntent.SetType("image/*"); galleryIntent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(galleryIntent, "select"), PickImageID); }; textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build(); if (!textRecognizer.IsOperational) { //todo:exception } else { cameraSource = new CameraSource.Builder(ApplicationContext, textRecognizer) .SetFacing(CameraFacing.Back) .SetRequestedPreviewSize(1280, 1024) .SetRequestedFps(2.0f) .SetAutoFocusEnabled(true) .Build(); surfaceView.Holder.AddCallback(this); textRecognizer.SetProcessor(this); } }
public OcrService() { _recognizer = new TextRecognizer .Builder(Platform.CurrentActivity) .Build(); }
void UseTextRecognitionModel() { System.Diagnostics.Debug.WriteLine($"##### {currentTxtRecogScript}"); CommonTextRecognizerOptions options = currentTxtRecogScript switch { TextRecognitionScript.Latin => new LatinTextRecognizerOptions(), TextRecognitionScript.Chinese => new ChineseTextRecognizerOptions(), TextRecognitionScript.Devanagari => new DevanagariTextRecognizerOptions(), TextRecognitionScript.Japanese => new JapaneseTextRecognizerOptions(), TextRecognitionScript.Korean => new KoreanTextRecognizerOptions(), _ => throw new NotImplementedException() }; var textRecognizer = TextRecognizer.TextRecognizerWithOptions(options); var image = new MLImage(ImgSample.Image); textRecognizer.ProcessImage(image, (text, err) => { TxtData.Text = err?.Description ?? text?.Text; }); } void UseFaceDetectionModel() { var options = new FaceDetectorOptions(); options.PerformanceMode = FacePerformanceMode.Accurate; options.LandmarkMode = FaceLandmarkMode.All; options.ClassificationMode = FaceClassificationMode.All; var faceDetector = FaceDetector.FaceDetectorWithOptions(options); var image = new MLImage(ImgSample.Image); faceDetector.ProcessImage(image, HandleFaceDetectorCallback); void HandleFaceDetectorCallback(Face [] faces, NSError error) { if (error != null) { TxtData.Text = error.Description; return; } if (faces == null || faces.Length == 0) { TxtData.Text = "No faces were found."; return; } var imageSize = ImgSample.Image.Size; UIGraphics.BeginImageContextWithOptions(imageSize, false, 0); var context = UIGraphics.GetCurrentContext(); context.SetStrokeColor(UIColor.Red.CGColor); context.SetLineWidth(10); ImgSample.Image.Draw(CGPoint.Empty); foreach (var face in faces) { context.AddRect(face.Frame); context.DrawPath(CGPathDrawingMode.Stroke); } var newImage = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); ImgSample.Image = newImage; } } void UseBarcodeScanningModel() { var options = new BarcodeScannerOptions(BarcodeFormat.All); var barcodeScanner = BarcodeScanner.BarcodeScannerWithOptions(options); var image = new MLImage(ImgSample.Image); barcodeScanner.ProcessImage(image, HandleBarcodeScannerCallback); void HandleBarcodeScannerCallback(Barcode [] barcodes, NSError error) { if (error != null) { TxtData.Text = error.Description; return; } if (barcodes == null || barcodes.Length == 0) { TxtData.Text = "No barcodes were found."; return; } var stringBuilder = new StringBuilder(); foreach (var barcode in barcodes) { stringBuilder.AppendLine($"Raw Value: {barcode.RawValue}"); stringBuilder.AppendLine($"Display Value: {barcode.DisplayValue}"); stringBuilder.AppendLine($"Format: {barcode.Format}"); stringBuilder.AppendLine($"Value Type: {barcode.ValueType}"); stringBuilder.AppendLine(); } TxtData.Text = stringBuilder.ToString(); } } void UseDigitalInkRecognitionModel() { strokes.Clear(); if (inkRecognizer == null) { var lang = "en-US"; var identifier = DigitalInkRecognitionModelIdentifier.ModelIdentifierForLanguageTag(lang); var model = new DigitalInkRecognitionModel(identifier); var modelManager = ModelManager.DefaultInstance; var conditions = new ModelDownloadConditions(true, true); // This works on device, but downloads seems to fail on simulators modelManager.DownloadModel(model, conditions); var options = new DigitalInkRecognizerOptions(model); inkRecognizer = DigitalInkRecognizer.DigitalInkRecognizerWithOptions(options); } } void UseImageLabeling() { var options = new ImageLabelerOptions(); options.ConfidenceThreshold = 0.7; var labeler = ImageLabeler.ImageLabelerWithOptions(options); var image = new MLImage(ImgSample.Image); labeler.ProcessImage(image, (labels, error) => { if (error != null) { TxtData.Text = error.Description; return; } if (labels == null || labels.Length == 0) { TxtData.Text = "No labels were found."; return; } var stringBuilder = new StringBuilder(); for (var i = 0; i < labels.Length; i++) { stringBuilder.AppendLine($"Label: {i}"); stringBuilder.AppendLine($"Text: {labels [i].Text}"); stringBuilder.AppendLine($"Confidence: {labels [i].Confidence}"); stringBuilder.AppendLine($"Index: {labels [i].Index}"); stringBuilder.AppendLine(); } TxtData.Text = stringBuilder.ToString(); }); } void UseObjectDetectionAndTracking() { var options = new ObjectDetectorOptions(); options.Mode = DetectorMode.SingleImage; options.ShouldEnableClassification = true; options.ShouldEnableMultipleObjects = true; var objectDetector = ObjectDetector.ObjectDetectorWithOptions(options); var image = new MLImage(ImgSample.Image); objectDetector.ProcessImage(image, (objects, error) => { if (error != null) { TxtData.Text = error.Description; return; } if (objects == null || objects.Length == 0) { TxtData.Text = "No objects were found."; return; } var imageSize = ImgSample.Image.Size; UIGraphics.BeginImageContextWithOptions(imageSize, false, 0); var context = UIGraphics.GetCurrentContext(); context.SetStrokeColor(UIColor.Red.CGColor); context.SetLineWidth(10); ImgSample.Image.Draw(CGPoint.Empty); var stringBuilder = new StringBuilder(); for (var i = 0; i < objects.Length; i++) { stringBuilder.AppendLine($"Object: {i}"); stringBuilder.AppendLine($"Tracking ID: {objects [i].TrackingId?.Int32Value ?? 0}"); foreach (var lbl in objects[i].Labels) { stringBuilder.AppendLine($" - Text: {lbl.Text}"); stringBuilder.AppendLine($" - Confidence: {lbl.Confidence}"); stringBuilder.AppendLine($" - Index: {lbl.Index}"); } stringBuilder.AppendLine(); context.AddRect(objects [i].Frame); context.DrawPath(CGPathDrawingMode.Stroke); } var newImage = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); ImgSample.Image = newImage; TxtData.Text = stringBuilder.ToString(); }); } #endregion #region Digital Ink const int msPerTimeInterval = 1000;