# EasyOCR - Reading Texts

<a id="easyocr-workflow"></a>

## Workflow

The **EasyOCR** optical character recognition library reads short texts (such as serial numbers, part numbers and dates).

It uses font files (pre-defined OCR-A, OCR-B and Semi-standard fonts, or other learned fonts) with a template matching algorithm that can recognize even badly printed, broken or connected characters of any size.

There are 4 steps to recognizing characters:

| ![image](assets/images/easyocr1/raw_image.webp)   | ![image](assets/images/easyocr1/object_segmentation.webp)   | ![image](assets/images/easyocr1/character_isolation.webp)   | ![image](assets/images/easyocr1/character_recognition.webp)   |
|---------------------------------------------------|-------------------------------------------------------------|-------------------------------------------------------------|---------------------------------------------------------------|
![image](assets/images/easyocr1/easyocrworkflow4.webp)

<a id="easyocr-learning-process"></a>

## Learning Process

You can learn characters to create a font file if required. Characters are presented one by one to **EasyOCR**, which analyzes them and builds a database of characters called a font. Each character has a numeric code (usually its ASCII code) and belongs to a **character class** (which may be used in the recognition process).

Font files are created as follows:

1. [`EOCR::NewFont`](../../doxygen_cpp/classeVision_1_1EOCR.html#a06855155687fbb8494daf1ac72a83b7e) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a3e0002af73f6a1462a5a0fb41c8b795d) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a879b41a49a25291afcd4f92d21f60635) clears the current font.
2. [`EOCR::LearnPattern`](../../doxygen_cpp/classeVision_1_1EOCR.html#afc8764f77cfb12ba09024db7c16c442e) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a22bf59aa00d9c0c2ae42d52c9c08156d) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a4eb6eb8bb53cd02a3561d364dabc93fa) or [`EOCR::LearnPatterns`](../../doxygen_cpp/classeVision_1_1EOCR.html#a9bbe3e4a66c5bfdf6e6e483e91f8a20b) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#aa5480c7879c4201dbbeb823ebac69c07) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#aaea348719f5e861cd0bbd6c9f04deec1) adds the patterns from the source image to the font. Patterns are ordered by their index value, as assigned by the [`EOCR::FindAllChars`](../../doxygen_cpp/classeVision_1_1EOCR.html#af8b6658ddc702d538f599fc2d50f7d33) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af9dc4be712674e3a8543d9b38860159b) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#afb0cd4050b95a06d2bee88438dfd0cdc) process. The patterns in a font are stored as a small array of pixels, by default 5 pixels wide and 9 pixels high. This can be changed when calling [`EOCR::NewFont`](../../doxygen_cpp/classeVision_1_1EOCR.html#a06855155687fbb8494daf1ac72a83b7e) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a3e0002af73f6a1462a5a0fb41c8b795d) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a879b41a49a25291afcd4f92d21f60635).
3. [`EOCR::RemovePattern`](../../doxygen_cpp/classeVision_1_1EOCR.html#a6976bbc2f78bb63d08285f6e89af5922) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a1743b84bc7cec961de57bf564c53cf34) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a0d8779e8c9324ee77926a805f24fc8a5) removes unwanted patterns (optional).
4. [`EOCR::Save`](../../doxygen_cpp/classeVision_1_1EOCR.html#a1e9fb381a88d5041c30c289e1c247f44) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a803e31ec01e72186953f1172aa15e319) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a615994f48851354031ce15dc26ea0886) writes the contents of the font to a disk file with parameter values: [`EOCR::SetNoiseArea`](../../doxygen_cpp/classeVision_1_1EOCR.html#a9c843eb5c699fbdc02902d2b1997c293) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a8e4fcefd8150b3149eb9324260d846d9) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a427e91396a037097105de907350c44ca), [`EOCR::SetMaxCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae8c85378d1bf4c72f635e5f385a73bc9) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af113b3f59d667f341ca75dea2afe4e27) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3c2659cd76112c237cadad69c50a8958), [`EOCR::SetMaxCharHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#ad6961eb9742559bac8d9774438d522f3) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a9a76a053bd1d36f7b557c76d5a521a9c) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a0d286787de629f7ea653feb549b37ad7), [`EOCR::SetMinCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#a71e9914413f4266393f8ad2104a50187) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a4f2d6039d7ef7c774544968d8c3fe14a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a809d442091df9247f9cb328ff4be6a7c), [`EOCR::SetMinCharHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#a8c9c71eb4f8cc7a263a83df05435688b) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#ac48ce3acf8f95a17da6eb108f8cab67c) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a49d27d8b67d7ac584c3e664703d2f624), [`EOCR::SetCharSpacing`](../../doxygen_cpp/classeVision_1_1EOCR.html#a6ee0f04d5951b8efe937b7ccc8b2ea51) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#aff626d2d38e635c983081eb9c0b67d52) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#aea3b6a664757ce62e13cfd1af65ac6aa), [`EOCR::SetTextColor`](../../doxygen_cpp/classeVision_1_1EOCR.html#a91a7498c5d100201e4665dfd4a8db259) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#adfb04764da5bbddb5b85276d0c9fa541) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#afd5053420e5863a234ccd03d771ae30d).

<a id="easyocr-segmenting"></a>

## Segmenting

1. **EasyOCR** analyzes the blobs to locate the characters and their bounding box, using one of two **segmentation modes** ([`EOCR::SetSegmentationMode`](../../doxygen_cpp/classeVision_1_1EOCR.html#a57560e5b64e6a305b349bae93b60ccb2) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a9b63212c259dc772fc5d46e12adb29c0) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a82eea8960c76be596b16af8f55627158)):
   * **keep objects** mode: one blob corresponds to one character.
   * **repaste objects** mode: the blobs are grouped into characters of a nominal size. This is useful when characters are broken or made up of several parts. When a blob is too large to be considered a single character, it can be split automatically using [`EOCR::SetCutLargeChars`](../../doxygen_cpp/classeVision_1_1EOCR.html#a681003dad040045c00800a38502346b0) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#acd8086f79014955ba82a96b5a718ab2a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a7c7a86e044643a879edc9c52fde6ebc3).

   ![](assets/images/easyocr1/charactersegmentationblobgrouping1.webp)![](assets/images/easyocr1/charactersegmentationblobgrouping2.webp)
2. Filters remove very large and very small unwanted features.
3. **EasyOCR** processes the character image to normalize the size to fit within a bounding box, extracts relevant features, and stores them in the font file. The patterns in a font are stored as arrays of pixels defined by [`EOCR::GetPatternWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ad0f6229c0313e8eba6ac9d3264990351) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a840bfa94d73464181d7447582b471d70) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a50b61df75e834de2dd0b6f6296f2e1e8) and [`EOCR::GetPatternHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#af53eab1a1382391773ccd3196c6bdd73) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a0717c7fb29a9b0d8318363eacc7bfb29) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a565758b83a40056f27aee8ea166fc89d) (by default 5 pixels wide and 9 pixels high).

<a id="easyocr-segmentation-parameters"></a>

### Segmentation Parameters

Segmentation parameters must be the same during learning and recognition. Good segmentation improves recognition.

* The [`EOCR::SetThreshold`](../../doxygen_cpp/classeVision_1_1EOCR.html#a50a225ac5f9843f3e287f5392ae9b009) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#afd18fa4f76f3b396dd17d232c9426662) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#aa52073a43bb36955c67f698c980a88b0) parameter helps separate the text from the background. Too high a value thickens black characters on a white background and may cause merging; too small a value makes parts disappear. If the lighting conditions are very variable, automatic thresholding is a good choice.
  ![](assets/images/easyocr1/toohighthreshold.webp)![](assets/images/easyocr1/correctthreshold.webp)![](assets/images/easyocr1/toolowthreshold.webp)
* [`EOCR::SetNoiseArea`](../../doxygen_cpp/classeVision_1_1EOCR.html#a9c843eb5c699fbdc02902d2b1997c293) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a8e4fcefd8150b3149eb9324260d846d9) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a427e91396a037097105de907350c44ca): Blob areas smaller than this value are discarded. Make sure small character features are preserved (i.e., the dot over an `i` letter).
* [`EOCR::SetMaxCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae8c85378d1bf4c72f635e5f385a73bc9) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af113b3f59d667f341ca75dea2afe4e27) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3c2659cd76112c237cadad69c50a8958), [`EOCR::SetMaxCharHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#ad6961eb9742559bac8d9774438d522f3) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a9a76a053bd1d36f7b557c76d5a521a9c) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a0d286787de629f7ea653feb549b37ad7): Maximum character size. If a blob does not fit in a rectangle with these dimensions, it is discarded or split into several parts using vertical cutting lines. If several blobs fit in a rectangle with these dimensions, they are grouped together.
* [`EOCR::SetMinCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#a71e9914413f4266393f8ad2104a50187) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a4f2d6039d7ef7c774544968d8c3fe14a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a809d442091df9247f9cb328ff4be6a7c), [`EOCR::SetMinCharHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#a8c9c71eb4f8cc7a263a83df05435688b) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#ac48ce3acf8f95a17da6eb108f8cab67c) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a49d27d8b67d7ac584c3e664703d2f624): Minimum character size. If a blob or a group of blobs fits in a rectangle with these dimensions, it is discarded.
* [`EOCR::SetCharSpacing`](../../doxygen_cpp/classeVision_1_1EOCR.html#a6ee0f04d5951b8efe937b7ccc8b2ea51) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#aff626d2d38e635c983081eb9c0b67d52) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#aea3b6a664757ce62e13cfd1af65ac6aa): The width of the smallest gap between adjacent letters. If it is larger than [`EOCR::SetMaxCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae8c85378d1bf4c72f635e5f385a73bc9) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af113b3f59d667f341ca75dea2afe4e27) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3c2659cd76112c237cadad69c50a8958) it has no effect. If the gap between two characters is wider than this, they are treated as different characters. This prevents thin characters from being incorrectly grouped together.
* [`EOCR::SetRemoveBorder`](../../doxygen_cpp/classeVision_1_1EOCR.html#a07a39008ca5846bc28566f4463cad489) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a4ff4f2b3655771c7ed1b41dc200a090f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#aa4484de02c25af9de320d5c87b029e14): Blobs near image/ROI edges cannot normally be exploited for character recognition. By default, they are discarded.

<a id="easyocr-recognition"></a>

## Recognition

The characters are compared to a set of patterns, called a **font**. A character is recognized by finding the best match between a character and a pattern in the font. After the character has been located, it is normalized in size (stretched to fit in a predefined rectangle) for matching. The normalized character is compared to each normalized template in the font database and the best matches are returned.

1. [`EOCR::Load`](../../doxygen_cpp/classeVision_1_1EOCR.html#a82e426d0bff454ebe86abfa14dd8f74f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#abc09dbb2aeee60ed2e16c71710077b3a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a55bb4431b3e5cba105d0526063afaacd): reads a pre-recorded font from a disk file.
2. [`EOCR::BuildObjects`](../../doxygen_cpp/classeVision_1_1EOCR.html#a7bfddae7675c34a7627a42a7d145363e) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a3e8d0e47ac44cbf40cc250acbbd8aabb) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#ab4e986a8c1aaecc44cb36400400861cf): The image is segmented into **objects** or blobs (connected components) which help find the **characters**. This step can be bypassed if the exact position of the characters is known. If the character isolation process is bypassed, you must specify the known locations of the characters: [`EOCR::AddChar`](../../doxygen_cpp/classeVision_1_1EOCR.html#a11ebfbedd7c40bab32d259a308863dc1) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#ad2f5ec6aaf7ae40e8d8600bfbbd794e2) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#ad7d1a4893fb3833135a4736ae7517762) and [`EOCR::EmptyChars`](../../doxygen_cpp/classeVision_1_1EOCR.html#a95a92f6952489e448860690b2c641c97) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a30f7470f859048c4347b331a3ae00f2f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3d327f2dde9d492fd5012bad98d3a05b).
3. [`EOCR::FindAllChars`](../../doxygen_cpp/classeVision_1_1EOCR.html#af8b6658ddc702d538f599fc2d50f7d33) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af9dc4be712674e3a8543d9b38860159b) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#afb0cd4050b95a06d2bee88438dfd0cdc): selects the objects considered as characters and sorts them from top to bottom then left to right.
4. [`EOCR::ReadText`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae213b2193cdd64173f0bbc32b23d801a) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a2c252361ea520d82783d451480d83e0b) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#afed5253767dd13bc54385cbf60d15e62): performs the matching and filters characters if the marking structure is fixed or a character set filter was provided.
   * **Character recognition**: The characters are compared to a set of patterns, called a **font**. The character is stretched to fit in a predefined rectangle and compared to each normalized template in the font database.
   * A **character set filter** can improve recognition reliability and run time by restricting the range of characters to be compared. For instance, if a marking always consists of two uppercase letters followed by five digits, the last of which is always even, it is possible to assign each character a class (maximum 32 classes) then set the character filter to allow the following classes at recognition time: two uppercase letters, four even or odd digits, one even digit.

Steps 2 to 4 can be repeated at will to process other images or ROIs. The [`EOCR::Recognize`](../../doxygen_cpp/classeVision_1_1EOCR.html#a75fa619140de2614ec0847df09023138) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af1994c767a2c892ad17bb4ad72acdeac) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#aecb017230592da5bf934c0541a4cd227) method can be used as well.

Additional information, such as the geometric position of the detected characters, can be obtained using: [`EOCR::CharGetOrgX`](../../doxygen_cpp/classeVision_1_1EOCR.html#ad5aeade5e8e6d4384f72895df1ca81a5) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a5d6653b0d983cecc62200f44a2648977) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a0987c85cf6c20c6c8f1f9a5c2a0ff26c), [`EOCR::CharGetOrgY`](../../doxygen_cpp/classeVision_1_1EOCR.html#ad618452a85bb5aa60caae88375992fa0) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#afb55cfcfbf1aa0cb976930294007a676) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a4673370bf8fc612c16993964b001e8df), [`EOCR::CharGetWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#aff39bd4cf43661f9338971cca65cc4a8) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a62e5c215a29c6903273b78785488621c) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#af8aa81b55a76109891a62c42bb9fdd90), [`EOCR::CharGetHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#ad9d70d84000fb0007b0e23bb06cc7099) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a4177cca45799ec81afde15f7bc95faef) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a2a9a5012bf14e3979bd89bd7388c38d4), …

[`EOCR::SetCompareAspectRatio`](../../doxygen_cpp/classeVision_1_1EOCR.html#af1a5d2207122022140f06ef93e3f6673) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a424e5e828634f52e908f5bc90f57c587) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a38562951f212bf6faded553c7cce74b7) makes character and font comparison sensitive to the difference between narrow and wide characters. It improves recognition when characters look like each other after size normalization.

<a id="easyocr-recognition-parameters"></a>

## Recognition Parameters

* [`EOCR::SetMaxCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae8c85378d1bf4c72f635e5f385a73bc9) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af113b3f59d667f341ca75dea2afe4e27) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3c2659cd76112c237cadad69c50a8958), [`EOCR::SetMaxCharHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#ad6961eb9742559bac8d9774438d522f3) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a9a76a053bd1d36f7b557c76d5a521a9c) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a0d286787de629f7ea653feb549b37ad7): if a blob does not fit within a rectangle with these dimensions, it is not considered as a possible character (too large) and is discarded. Furthermore, if several blobs fit in a rectangle with these dimensions, they are grouped together, forming a single character. The outer rectangle size should be chosen such that it can contain the largest character from the font, enlarged by a small safety margin.
* [`EOCR::SetMinCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#a71e9914413f4266393f8ad2104a50187) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a4f2d6039d7ef7c774544968d8c3fe14a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a809d442091df9247f9cb328ff4be6a7c), [`EOCR::SetMinCharHeight`](../../doxygen_cpp/classeVision_1_1EOCR.html#a8c9c71eb4f8cc7a263a83df05435688b) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#ac48ce3acf8f95a17da6eb108f8cab67c) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a49d27d8b67d7ac584c3e664703d2f624): if a blob or a group of blobs fits in a rectangle with these dimensions, it is not considered as a possible character (too small) and is discarded. The inner rectangle size should be chosen such that it is contained in the smallest character from the font, shrunk by a small safety margin.
* [`EOCR::SetRemoveNarrowOrFlat`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae0304e2991647526933ba87d0fc75ab3) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a2d2b2ca87454e4b545b761f2edd6896b) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a830dc6fc0e8c8ec5ca8385c2fdadd6c1): Small characters are discarded if they are narrow **or** flat. By default, they are discarded when they are both narrow **and** flat.
* [`EOCR::SetCharSpacing`](../../doxygen_cpp/classeVision_1_1EOCR.html#a6ee0f04d5951b8efe937b7ccc8b2ea51) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#aff626d2d38e635c983081eb9c0b67d52) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#aea3b6a664757ce62e13cfd1af65ac6aa): if two blobs are separated by a vertical gap wider than this value, they are considered to belong to different characters. This feature is useful to avoid the grouping of thin characters that would fit in the outer rectangle. Its value should be set to the width of the smallest gap between adjacent letters. If it is set to a large value (larger than [`EOCR::SetMaxCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae8c85378d1bf4c72f635e5f385a73bc9) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af113b3f59d667f341ca75dea2afe4e27) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3c2659cd76112c237cadad69c50a8958)), it has no effect.
* [`EOCR::SetCutLargeChars`](../../doxygen_cpp/classeVision_1_1EOCR.html#a681003dad040045c00800a38502346b0) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#acd8086f79014955ba82a96b5a718ab2a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a7c7a86e044643a879edc9c52fde6ebc3): when a blob or grouping of blobs is larger than [`EOCR::SetMaxCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae8c85378d1bf4c72f635e5f385a73bc9) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af113b3f59d667f341ca75dea2afe4e27) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3c2659cd76112c237cadad69c50a8958), it is discarded. When enabled, the blob is split into as many parts as necessary to fit and the amount of white space to be inserted between the split blobs is set by [`EOCR::SetRelativeSpacing`](../../doxygen_cpp/classeVision_1_1EOCR.html#a2930e0cf7627bdffa8197de5cbadd246) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a1f35b7f29a5f756771b3a95e2e8ff3d4) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#ae79ab039ffcf8dbb0b1cb1f9eda6d498). This is an attempt to separate touching characters.
* [`EOCR::SetRelativeSpacing`](../../doxygen_cpp/classeVision_1_1EOCR.html#a2930e0cf7627bdffa8197de5cbadd246) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a1f35b7f29a5f756771b3a95e2e8ff3d4) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#ae79ab039ffcf8dbb0b1cb1f9eda6d498): when the [`EOCR::SetCutLargeChars`](../../doxygen_cpp/classeVision_1_1EOCR.html#a681003dad040045c00800a38502346b0) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#acd8086f79014955ba82a96b5a718ab2a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a7c7a86e044643a879edc9c52fde6ebc3) mode is enabled, setting this value allows specifying the amount of white space that should be inserted between the split parts of the blobs.

![image](assets/images/easyocr1/invalidrecognitionsettings.webp)

<a id="easyocr-advanced-tuning"></a>

### Advanced Tuning

These recognition parameters can be tuned to optimize recognition:

* [`EOCR::SetCompareAspectRatio`](../../doxygen_cpp/classeVision_1_1EOCR.html#af1a5d2207122022140f06ef93e3f6673) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a424e5e828634f52e908f5bc90f57c587) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a38562951f212bf6faded553c7cce74b7): when this setting is on, it is less tolerant of size and takes into account the measured aspect ratio. Using this mode improves the recognition when characters look similar after size normalization as it enforces the difference between narrow and wide characters.
* Filtering the characters (in the [`EOCR::ReadText`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae213b2193cdd64173f0bbc32b23d801a) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a2c252361ea520d82783d451480d83e0b) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#afed5253767dd13bc54385cbf60d15e62) method) can be used if the marking structure is fixed.
* When objects are larger than the [`EOCR::SetMaxCharWidth`](../../doxygen_cpp/classeVision_1_1EOCR.html#ae8c85378d1bf4c72f635e5f385a73bc9) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#af113b3f59d667f341ca75dea2afe4e27) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a3c2659cd76112c237cadad69c50a8958) property, they can be split into as many parts as needed, using vertical cutting lines.
* [`EOCR::SetSegmentationMode`](../../doxygen_cpp/classeVision_1_1EOCR.html#a57560e5b64e6a305b349bae93b60ccb2) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#a9b63212c259dc772fc5d46e12adb29c0) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#a82eea8960c76be596b16af8f55627158) defines how characters are isolated:
  * **Keep objects** mode: a character is a blob; no attempt is made to group blobs, thus damaged characters cannot be handled and small features such as accents and dots may be discarded by the minimum character size criterion.
  * **Repaste objects** mode: blobs are grouped to form distinct **characters** if they fit in the maximum character size and are not separated by a vertical gap, thus preserving accents and dots.
* By default, **EasyOCR** considers two characters to be on different lines if their baselines differ by more than approximately 30% of the character height. Use the property [`EOCR::SetLineSpacingMode`](../../doxygen_cpp/classeVision_1_1EOCR.html#a8ef8a59a4ed8c4ec6e4fe356dc92ca12) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EOCR.html#afa1b0d554c49b5525db3cb765ae6217f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EOCR.html#adc693ed3e1c4deb51c10affcb6ad8a34) to change that behavior.

<a id="easyocr-quick-links"></a>

## See Also

Easy to understand, ready to copy code snippets.

Sample reading image using **EasyOCR**
