/// <summary> /// Perform OCR and get text from the given image /// </summary> /// <param name="image">Text from the image</param> public void GetTextFromImage(Bitmap image) { try { // Turn image into Page (needed for OCR) TempImageStorage storage = new TempImageStorage(); storage.AddImage(image); var images = storage.GetImages(); var path = FileChooserUtils.GetPath(activity, images[0]); var imageFile = new Java.IO.File(path); var pages = new List <Page>(); var page = pageFactory.BuildPage(imageFile); pages.Add(page); // Result of the whole recognition var fullOcrResult = textRecognition.WithoutPDF(ocrLanguages, pages).Recognize(); // Call the event in the case of success if (OnOCRComplete != null) { // Save the recognized text in the event argument activity.RunOnUiThread(() => OnOCRComplete(this, new OCRText(fullOcrResult.RecognizedText))); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Error performing OCR" + e.Message); } }
public static string[] GetSelectedImagesAsFilePaths(List <Uri> selectedImages, Activity activity) { var result = new List <string>(); foreach (var androidUri in selectedImages) { result.Add(FileChooserUtils.GetPath(activity, androidUri)); } return(result.ToArray()); }
public static Bitmap LoadImage(Uri imageUri, Activity activity) { return(LoadImage(FileChooserUtils.GetPath(activity, imageUri))); }