<a id="edo-detailed-usage"></a>

# Detailed Usage

<a id="edo-reading-a-text"></a>

## Reading a Text

The core class of **EasyDeepOCR** is the [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html).

In order to read a text, create a new `ETextReader` instance and initialize it using [`ETextReader::Initialize()`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a8aa4a233c236ab66c860b792fdd8fbc3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a5ca732cfe514ac1ca50059551abba832) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a05a2381cf55e5a93bc140d58c3de4661). To read the texts in a loaded image, use [`ETextReader::Read()`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a89af65e87d9b4bcb08c67ccb6144bef6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ab4c5317f2a21715a57f29a5d7f28f4d1) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a74442f7cf99d92154de65b581cdc78a8). This method will return a vector of [`EasyDeepOCR::EText`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html).

#### NOTE
When the topology is not specified, the returned [`EText`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html) always contains a single [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html).

#### NOTE
The method [`ETextReader::Initialize`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a8aa4a233c236ab66c860b792fdd8fbc3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a5ca732cfe514ac1ca50059551abba832) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a05a2381cf55e5a93bc140d58c3de4661) is designed to pre-allocate memory and to load the necessary resources needed by the [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html).

* This initialization can be time-consuming, but it must only be performed once after an instantiation, a loading from memory or a copy from another instance.
* The duration of the process ranges from a few seconds to several minutes, depending on the execution settings and the computing platform.

#### SEE ALSO
[Code snippet](../../../resources/code_snippets/text_and_code_reading/easydeepocr/readingatext.html.md)

<a id="edo-getting-a-score"></a>

## Getting a Score

Each [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) and [`EText`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html) returned by the [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) has a score attached to it.

<a id="edo-textline-score"></a>

### The score of an `ETextLine`

The score of an [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html):

* Is the arithmetic mean of the detection score and the recognition score.
* Is in the interval `[0.0; 1.0]`.
* You can use it to get an approximation of the reading quality of the underlying text.

Use [`ETextLine::GetScore`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html#a174f9f47b9383c454448bb278eedfd2a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html#a2e6c59307ede3648487696bf34215944) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html#a8a9d5c721ded2d2ed8682a25de9b8a24) to get the score of an `ETextLine`.

<a id="edo-text-score"></a>

### The score of an `EText`

The score of an [`EText`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html) (that is composed of multiple [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html)):

* Is the average of all line scores
* Is in the interval `[0.0; 1.0]`.
* You can use it to get an approximation of the reading quality of the underlying lines.

Use [`EText::GetScore`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html#adadf2b57d7b31c55f4d4a46536622e36) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html#aefc37fbf862806da1c04ef3d303c889c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html#aa7091855901fb5b51fe8cbe7ec0c3064) to get the score of an `EText`.

#### SEE ALSO
[Code snippet](../../../resources/code_snippets/text_and_code_reading/easydeepocr/getscore.html.md)

<a id="edo-drawing-textline-or-text"></a>

## Drawing an ETextLine or an EText

* Use the methods `Draw` to graphically draw an [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) or an [`EText`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html).
* Use the class [`ETextDrawingParameters`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextDrawingParameters.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextDrawingParameters.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextDrawingParameters.html) to set the drawing attributes and display:
  * The text box.
  * The text line box.
  * The text string.
  * The text direction, with a configurable arrow length.

  ![](assets/images/easydeepocr/drawing_an_etext.webp)

#### SEE ALSO
[Sample program](../../../resources/sample_programs/text_and_code_reading/easydeepocrread.html.md)

<a id="edo-specifying-topology"></a>

## Specifying a Topology

A topology is a canvas that a given string can satisfy, or not.

Specifying a topology improves the relevance of the outputs of [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) because only the texts that fit into the canvas are returned. Before applying this filter, the [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) tries to correct a few small mistakes in order to prevent excessive filtering. In addition, the topology triggers the grouping of lines into texts. In other words, an [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) returns [`EText`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html) composed of several [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) only when several lines are required by the topology.

In practice, a topology is an instance of the class [`ETopology`](../../../doxygen_cpp/classeVision_1_1ETopology.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ETopology.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETopology.html), which is basically a vector of [`ETopologyLine`](../../../doxygen_cpp/classeVision_1_1ETopologyLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ETopologyLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETopologyLine.html), with the nth entry referring to the nth text line. As mentioned previously, a topology thus never matches a text whose number of lines is different from the size of the vector [`ETopologyLine`](../../../doxygen_cpp/classeVision_1_1ETopologyLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ETopologyLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETopologyLine.html).

The canvas mentioned in the first paragraph must be specified inside the class [`ETopologyLine`](../../../doxygen_cpp/classeVision_1_1ETopologyLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ETopologyLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETopologyLine.html) and in particular, by setting its “format string”. This “format string” is a string that can be interpreted using:

* The **eVision** simplified format
* A standard regular expression format.

#### SEE ALSO
[Code snippet](../../../resources/code_snippets/text_and_code_reading/easydeepocr/specifyingatopology.html.md)

<a id="edo-evision-simplified-format"></a>

### The eVision Simplified Format

* Each character from the “format string” represents a “character class”.
* An [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) satisfies the [`ETopologyLine`](../../../doxygen_cpp/classeVision_1_1ETopologyLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ETopologyLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETopologyLine.html) if each of its characters belongs to the corresponding “character class” specified by the “format string”.
* The **eVision** simplified format is composed of the following eight “character classes”:
  * `A`: an uppercase ASCII letter: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
  * `a`: a lowercase ASCII letter: `abcdefghijklmnopqrstuvwxyz`
  * `0`: a digit: `0123456789`
  * `P`: an ASCII punctuation character: `!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~`
  * `V`: a character belonging to either A or 0
  * `X`: a character belonging to either A, a, 0 or P
  * ` `: a space
  * `S`: a character belonging to either X or a space

<a id="edo-literal-groups"></a>

### “Literal Groups”

* You can specify a “literal group”, that is a group of characters that should appear verbatim in the [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html).
  * These “literal groups” must be included inside square brackets `[]`. Note that square brackets themselves must not appear in a literal group.
* For more flexibility, you can use a “range quantifier” or an “exact quantifier” just after a “character class”:
  * Add a “range quantifier” as `{m,n}` to specify that the preceding “character class” must be matched between `m` and `n` times.
  * Add an “exact quantifier” as `{n}` to specify that the preceding “character class” must be matched exactly `n` times.
* Examples
  * The “format string” `[Lot:] 00[-]0{1,3}` matches all the following strings:
    * `Lot: 12-783`
    * `Lot: 74-1`
    * `Lot: 09-447`
    * `Lot: 85-75`
  * The “format string” `[Exp:] 00[/]00[/]0{4}` matches all the following strings:
    * `Exp: 06/07/2024`
    * `Exp: 01/03/1995`
    * `Exp: 75/42/0065`
    * `Exp: 01/22/1569`

<a id="edo-regular-expression-format"></a>

### The Regular Expression Format

* The “format string” is a regular expression written using the **ECMAScript regular expression grammar**.
  * To learn how to use the regular expression format, see the [Regex 101](https://regex101.com/) web application.
  * This grammar is described in the [ECMAScript Language Specification, ECMA-262, Chapter 15 part 10, RegExp (Regular Expression) Objects](https://web.archive.org/web/20260831102636/https://262.ecma-international.org/5.1/#sec-15.10).

<a id="edo-setting-text-angle"></a>

## Setting the Text Angle

The text angle is an optional parameter of [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) that controls the reading direction of the texts that are returned.

* Use [`ETextReader::SetTextAngle`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a2c9a6af1bab6ba83699abaa446c10ca6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#af26d63afb6c8877206937bf7c6dafbea) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a031915c49655f185aaad366962c1b3e1) to set an angle and [`ETextReader::GetHasTextAngle`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a465890926bad485e99bfedd0887bf76c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a2bad996f04b4c5cd4a4cd31c4d4bed9b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a6e4113d0cfe79cbb076ba2296e33f38d) to check if an angle is specified.
  * When the text angle is set, [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) determines the direction of the texts by selecting the orientation that is closest to the specified angle among the four cardinal directions.

  #### HINT
  This is particularly useful when the approximate orientation of the texts is known.

| Text angle        | 10°                                              | 80°                                              | -120°                                            | -35°                                             |
|-------------------|--------------------------------------------------|--------------------------------------------------|--------------------------------------------------|--------------------------------------------------|
| Reading direction | ![](assets/images/easydeepocr/text_angle_1.webp) | ![](assets/images/easydeepocr/text_angle_2.webp) | ![](assets/images/easydeepocr/text_angle_3.webp) | ![](assets/images/easydeepocr/text_angle_4.webp) |
* Use [`ETextReader::UnsetTextAngle`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a2cb9394e27668cf71c9efee0b2f0b211) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#abb88bdab625b742144fd516059c6067f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ad54a20cf375e9f5e403d2aa33ae6740f) to delete any set angle.
  * When the text angle is not set, [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) automatically chooses the reading direction among the four cardinal directions based on its internal heuristics.

<a id="edo-performing-optimization"></a>

## Performing an Optimization

You can optimize the [`ETextReader`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html) for your own specific use case.

After this optimization:

* The reader only returns the texts that belong to the same “customer use case” as the one used for the optimization.
* The processing speed may increase.
* **EasyDeepOCR** may find challenging texts that were not detected before the optimization.

This optimization is based on the method [`ETextReader::Optimize`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a22f3b11b24552c6f07defbc033203741) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a9dd2fd7f7ac49b8235bb383662c80960) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#acd534b7cd06317be0bb6c3130673403b) that requires an instance of the class [`ESampleList`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ESampleList.html).

* The class [`ESampleList`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) is a container that gathers all the information about the “customer use case”.

  #### NOTE
  See section [Building a Sample List](setting_the_parameters.html.md#edo-building-sample-list).

Considering that the [`ESampleList`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ESampleList.html) is filled, the optimization only requires a few lines of code, as illustrated below.

### C++

```cpp
#include <eVision/EasyOcr/EasyDeepOCR/ETextReader.h>
```

```cpp
using namespace eVision;
namespace EDO = eVision::EasyDeepOCR;
// Create an ESample vector
std::vector<EDO::ESample> samples;
// Fill the vector
// ...
// Create an ESampleList instance
EDO::ESampleList sampleList;
// Set the samples
sampleList.SetSamples(samples);
// Create an ETextReader instance
EDO::ETextReader reader;
// Initialize the ETextReader
reader.Initialize();
// Optimize the ETextReader
EDO::EOptimizationReport report = reader.Optimize(sampleList); 
// ...
```

### C#

```cs
using eVision;
using EDO = eVision.EasyDeepOCR;
```

```cs
// Create an ESample vector
EDO.ESample[] samples = new EDO.ESample[] { } ;
// Fill the vector
// ...
// Create an ESampleList instance
EDO.ESampleList sampleList = new EDO.ESampleList();
// Set the samples
sampleList.Samples = samples;
// Create an ETextReader instance
EDO.ETextReader reader = new EDO.ETextReader();
// Initialize the ETextReader
reader.Initialize();
// Optimize the ETextReader
EDO.EOptimizationReport report = reader.Optimize(sampleList); 
// ...
```

### Python

```py
import eVision
from eVision import EasyDeepOCR as EDO
# Create an ESample vector
samples = []
# Fill the vector
# ...
# Create an ESampleList instance
sampleList = EDO.ESampleList()
# Set the samples
sampleList.Samples = samples
# Create an ETextReader instance
reader = EDO.ETextReader()
# Initialize the ETextReader
reader.Initialize()
# Optimize the ETextReader
report = reader.Optimize(sampleList); 
# ...
```

<a id="edo-splitting-pipeline"></a>

## Splitting the Pipeline

#### HINT
While the function [`ETextReader::Read`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a89af65e87d9b4bcb08c67ccb6144bef6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ab4c5317f2a21715a57f29a5d7f28f4d1) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a74442f7cf99d92154de65b581cdc78a8) is suitable for straightforward OCR tasks, the split pipeline becomes beneficial when you require a custom processing for a specific use case.

* The pipeline [`ETextReader::Read`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a89af65e87d9b4bcb08c67ccb6144bef6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ab4c5317f2a21715a57f29a5d7f28f4d1) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a74442f7cf99d92154de65b581cdc78a8) consists of 3 distinct functions that are invoked sequentially:
  * [`ETextReader::Localize`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a245b6f00ef57348eeffd81aa0cd7f9cf) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#af8851fdaeaca57e83e7e0e64afd23c74) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ac9b41c16d32f8ed43e4ab1efc9803975) detects the text areas.
  * [`ETextReader::Recognize`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a24c134563a6fcdc0b13ce92170b4eab9) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ac09f3e7b3d5497c0200a59b022387238) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a4901ea3a07c9085d16924e375d5fcdd5) converts the detected areas to strings.
  * [`ETextReader::Merge`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a21e26045505e85a374d18500a6b83c54) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#acbad3ca833948f87937fdae817b45fbe) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a82990a87ac8245e283f36f6688ca7cce) combines the text lines based on a topology, if specified.
* These 3 functions provide an enhanced control through capabilities such as:
  * Inserting custom processing between steps.
  * Skipping unnecessary steps.
  * Accessing intermediate results.
  * Applying different parameters for specific regions.

#### SEE ALSO
[Code snippet](../../../resources/code_snippets/text_and_code_reading/easydeepocr/splittingthepipeline.html.md)

<a id="edo-using-localize"></a>

### Using `ETextReader::Localize`

The method [`ETextReader::Localize`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a245b6f00ef57348eeffd81aa0cd7f9cf) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#af8851fdaeaca57e83e7e0e64afd23c74) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ac9b41c16d32f8ed43e4ab1efc9803975) identifies regions in an image that contain text lines and returns them as rectangles.

* This method is appropriate for identifying the locations of text lines in an image without reading their contents.
* This approach is particularly useful in scenarios where certain regions might need filtering based on size, position or other geometric properties before proceeding with the recognition.
* It also serves as an excellent first step when building a custom OCR pipeline that requires specialized handling of different text regions.

<a id="edo-using-recognize"></a>

### Using `ETextReader::Recognize`

The method [`ETextReader::Recognize`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a24c134563a6fcdc0b13ce92170b4eab9) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#ac09f3e7b3d5497c0200a59b022387238) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a4901ea3a07c9085d16924e375d5fcdd5) accepts an [`ERegion`](../../../doxygen_cpp/classeVision_1_1ERegion.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ERegion.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ERegion.html) or an [`ERectangle`](../../../doxygen_cpp/classeVision_1_1ERectangle.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ERectangle.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ERectangle.html) as input and outputs a [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html).

* It can work with either a miniature image containing only text or a region within a larger image.
* This method is particularly valuable when working with images that contain text in specific areas requiring different processing parameters, such as different topology constraints.

<a id="edo-using-merge"></a>

### Using `ETextReader::Merge`

The method [`ETextReader::Merge`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a21e26045505e85a374d18500a6b83c54) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#acbad3ca833948f87937fdae817b45fbe) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a82990a87ac8245e283f36f6688ca7cce) combines recognized multiple [`ETextLine`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextLine.html) into structured objects [`EText`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1EText.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1EText.html) based on the defined [`ETopology`](../../../doxygen_cpp/classeVision_1_1ETopology.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ETopology.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETopology.html).

* This method becomes valuable when working with images where the relationship between the text lines carries a semantic meaning.
* By organizing the text according to the topology, the method [`ETextReader::Merge`](../../../doxygen_cpp/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a21e26045505e85a374d18500a6b83c54) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#acbad3ca833948f87937fdae817b45fbe) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepOCR_1_1ETextReader.html#a82990a87ac8245e283f36f6688ca7cce) preserves the logical relationships between the different text elements.
