Recognize the Characters

See also: code snippets: Reading Using TrueType Fonts, Reading Using EOCR2 Character Database, Reading Using EOCR2 Model File

Recognition

&

To recognize characters, EasyOCR2 uses a pretrained classifier or a classifier that you trained on your character database.

For each input character:

The classifier calculates a score for all candidate outputs.
It returns the candidate with the highest score as the recognition result.

Use the topology to pass information to the classifier about each character. This reduces the number of candidates and improves the recognition rate (see Set the Topology).

&
Use the method Read or Recognize to retrieve a string with the recognition results.
Call Read to detect and recognize the characters in one step.
Call Detect to extract the text from the image then Recognize to recognize the extracted text. This allows you to modify elements of the detected text before the recognition.
To access more information about the results, use the method ReadText that returns an EOCR2Text structure with:
The coordinates and the size of each textbox,
A bitmap image of each textbox,
A list of the recognition scores for each character.

Process

2 Detect the characters in your image as described in Detect the Characters.
1. Select the Classifier used by EOCR2 for recognition.

By default:

EOCR2Classifier_DatabaseClassifier: EOCR2 uses the current character database.

Pretrained classifiers used in different contexts:

EOCR2Classifier_Industrial_A_Z_0_9_P for characters used in an industrial context without a specific font.
EOCR2Classifier_OCRA_A_Z_0_9_P for characters using the OCR-A font.
EOCR2Classifier_SEMI_A_Z_0_9_P for characters using the SEMI-OCR font.
2. Recognize or read the decoded text.

Read a model file

Use Load to read the model (.o2m) file from your disk.

The model file contains:

All the detection parameters,
The topology,
The reference character database.

Overriding the classifier

Use SetClassifier with a symbol and a classifier to override the current classifier and assign another classifier (EOCR2Classifier) to a specific symbol or a combination.

Currently you can override only the EOCR2Classifier_DatabaseClassifier.

Accelerate the recognition

A character is expected to be recognized in 4 ms, half of this with multithreading and even less with a GPU.

Multithreading

With pretrained classifiers, use Easy::GetMaxNumberOfProcessingThreads to multithread the recognition and to determine how many threads you can use for the recognition.

GPU acceleration

You can also use a compatible GPU to accelerate even more the recognition.
Use Easy::IsGPUAvailable to determine if there is a compatible GPU available.
Use EOCR2:SetEnableGPU(true) to enable the GPU-recognition.