public Scan ( byte>.Image |
||
image | byte>.Image | Source Image to be OCR-ed |
Результат | string |
/// <summary> /// Execute OCR on a given image, this static member will process the image, /// Safely open, execute and dispose a Tesseract Object and store the result /// in a new OcrData object. /// </summary> /// <param name="original"> Image to be OCR-ed </param> /// <param name="mode"> Accuracy setting </param> /// <param name="lang"> Language of text for OCR Language Model </param> /// <param name="enableTimer"> Measure the Scantime for Diagnostic purposes </param> /// <returns> </returns> public static OcrData Recognize(Bitmap original, Accuracy mode = Accuracy.High, string lang = "eng", bool enableTimer = false) { Image<Bgra, byte> img = new Image<Bgra, byte>(original); Image<Gray, byte> processed; Tesseract.Charactor[] chars; String text; long confidence; long scantime = Int64.MinValue; using (OCR ocr = new OCR(mode, lang, enableTimer)) { processed = ocr.Preprocess(img); ocr.Scan(processed); confidence = ocr.OverallCost(); chars = ocr.Charactors(); text = ocr.Text(); if (enableTimer) { scantime = ocr.Elapsed(); ocr.Stop(); } } img.Dispose(); if (scantime == Int64.MinValue) { return new OcrData(processed, chars, text, confidence); } return new OcrData(processed, chars, text, confidence, scantime); }
/// <summary> /// Execute OCR on a given image, this static member will process the image, /// Safely open, execute and dispose a Tesseract Object and store the result /// in a new OcrData object. /// </summary> /// <param name="original"> Image to be OCR-ed </param> /// <param name="mode"> Accuracy setting </param> /// <param name="lang"> Language of text for OCR Language Model </param> /// <param name="enableTimer"> Measure the Scantime for Diagnostic purposes </param> /// <returns> </returns> public static OcrData Recognize(Bitmap original, Accuracy mode = Accuracy.High, string lang = "eng", bool enableTimer = false) { Image<Bgra, byte> img = new Image<Bgra, byte>(original); Image<Gray, byte> processed; Tesseract.Charactor[] chars; String text; long confidence; long scantime = Int64.MinValue; using (OCR ocr = new OCR(mode, lang, enableTimer)) { processed = ocr.Preprocess(img); ocr.Scan(processed); confidence = ocr.OverallCost(); chars = ocr.Charactors(); text = ocr.Text(); if (enableTimer) { scantime = ocr.Elapsed(); ocr.Stop(); } } img.Dispose(); if (scantime == Int64.MinValue) { return new OcrData(processed, chars, text, confidence); } return new OcrData(processed, chars, text, confidence, scantime); }