/// <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 override void OnCreate() { base.OnCreate(); TempImageStorage = new TempImageStorage(GetExampleTempStorageDir()); Log.Debug(LOG_TAG, "Initializing Scanbot SDK..."); SBSDK.Initialize(this, LICENSE_KEY, new SBSDKConfiguration { EnableLogging = true }); // In this example we always cleanup the demo temp storage directory on app start. TempImageStorage.CleanUp(); }