New to Telerik Document ProcessingStart a free 30-day trial

OCR provider backed by the Tesseract engine that extracts text from images, configurable by language packs and data path.

Definition

Namespace:Telerik.Windows.Documents.TesseractOcr

Assembly:Telerik.Windows.Documents.TesseractOcr.dll

Syntax:

C#
public class TesseractOcrProvider : IOcrProvider

Inheritance: objectTesseractOcrProvider

Implements: IOcrProvider

Constructors

Creates a new instance of the TesseractOcrProvider class.

C#
public TesseractOcrProvider(string dataPath)
Parameters:dataPathstring

The path to the parent directory containing the tessdata directory. Ignored if the TESSDATA_PREFIX environment variable is set. If set to "." the tessdata directory should be in the same directory as the executable.

Properties

The path to the parent directory containing the tessdata directory. Ignored if the TESSDATA_PREFIX environment variable is set. "." by default. If left unchanged, the tessdata directory should be in the same directory as the executable.

C#
public string DataPath { get; set; }

The language codes to use for the Tesseract OCR engine. You can find the corresponding trained data for each language and their codes here: https://github.com/tesseract-ocr/tessdata

C#
public List<string> LanguageCodes { get; set; }

Gets or sets the granularity for recognized text (based on OcrParseLevel), which affects iterator level and output grouping.

C#
public OcrParseLevel ParseLevel { get; set; }

Implements: IOcrProvider.ParseLevel

Methods

Extracts all text from an image and returns it as a single string.

C#
public string GetAllTextFromImage(byte[] imageBytes)
Parameters:imageBytesbyte[]

The bytes of the image.

Returns:

string

The entire text as a string.

Implements: IOcrProvider.GetAllTextFromImage(byte[])

Extracts the text from an image and returns the words and their bounding rectangles.

C#
public Dictionary<Rectangle, string> GetTextFromImage(byte[] imageBytes)
Parameters:imageBytesbyte[]

The bytes of the image.

Returns:

Dictionary<Rectangle, string>

Words with corresponding bounding rectangles

Implements: IOcrProvider.GetTextFromImage(byte[])