<a id="ecodereader"></a>

# ECodeReader - Unified Interface

![image](assets/images/ecodereader/ecodereader.webp)

<a id="ecodereader-pruprose"></a>

## Purpose of **ECodeReader**

**ECodeReader** integrates the functionality of **EasyBarCode**, **EasyMatrixCode** and **EasyQRCode** in a single unified interface.

In a single [`ECodeReader::Read`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#ac4d131d9f3d4f049ec792cb09e748a0f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a5ed82f035549f108343a03613f51703f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#af120d89e856a5a6bdf8d96a33bb67da4) operation, **ECodeReader** locates and decodes the 3 kinds of codes supported by **eVision**, namely bar codes, QR codes and data matrix codes.

For more information about these codes and the associated support, please refer to the [EasyBarCode](easybarcode/easybarcode2.html.md), [EasyMatrixCode](easymatrixcode2/index.html.md) and [EasyQRCode](easyqrcode/index.html.md) user guides.

<a id="ecodereader-reading"></a>

## Reading a Set of Codes

You can read the codes in an image automatically as follows:

* Create an [`ECodeReader`](../../doxygen_cpp/classeVision_1_1ECodeReader.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html) object.
* Call the [`ECodeReader::Read`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#ac4d131d9f3d4f049ec792cb09e748a0f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a5ed82f035549f108343a03613f51703f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#af120d89e856a5a6bdf8d96a33bb67da4) method to return a vector of [`ECode`](../../doxygen_cpp/classeVision_1_1ECode.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html).
* Each instance contains, among others, the [`string`](../../doxygen_cpp/classeVision_1_1ECode.html#ac85cb88a6dbd8283e1274cb53cbdfecf) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#a9af2f11e45081455eea4f4241eaafe9a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#a0349c8feddaf3759fe2566042c0f2319) embedded in the code.

### C++

```cpp
#include <eVision/EasyID/ECodeReader.h>
```

```cpp
using namespace eVision;

// Image constructor
EImageBW8 srcImage;

// Bar code reader constructor
ECodeReader reader;

// Set the max number of codes of each type to find
reader.SetMaxNumCodesPerType(2);

// Read the barcodes in the source image
std::vector<ECode> results = reader.Read(srcImage);

// Get decoded string
std::string decodedString = results[0].GetDecodedString();
```

### C#

```cs
using eVision;
```

```cs
// Image constructor
EImageBW8 srcImage = new EImageBW8();

// Bar code reader constructor
ECodeReader reader = new ECodeReader();

// Set the max number of codes of each type to find
reader.MaxNumCodesPerType = 2;

// Read the bar codes in the source image
ECode[] results = reader.Read(srcImage);

// Get decoded string
string decodedString = results[0].DecodedString;
```

### Python

```py
import eVision

# Image constructor
srcImage = eVision.EImageBW8()

# Bar code reader constructor
reader = eVision.ECodeReader()

# Set the max number of codes of each type to find
reader.MaxNumCodesPerType = 2

# Read the bar codes in the source image
results = reader.Read(srcImage)

# Get decoded string
decodedString = results[0].DecodedString
```

<a id="ecodereader-parameters"></a>

## Read Parameters

* By default, [`ECodeReader`](../../doxygen_cpp/classeVision_1_1ECodeReader.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html) searches for all supported types of code in the image.
  * Use the property [`ECodeReader::GetEnabledCodeTypes`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#a58683fcfde0406f3879cb991c65310e8) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a4028ca7592dc4bb8e2061304fd3288b9) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#a9df144ac32637299fef5308859fbb5e0) if you want to disable (or enable) specific code types.

#### WARNING
If one of the supported types of code is not present in the image, it is recommended to disable that type. Otherwise the corresponding reader runs and may slow the whole process.

* Use [`ECodeReader::SetTimeOut`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#a0ead417b127e059609b24a08073cc7a2) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a81efea40b3df2784ae4a0f5113244b18) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#a90e7ba898415e1c0d42c947cfb39b52c) to set a time-out to the [`ECodeReader::Read`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#ac4d131d9f3d4f049ec792cb09e748a0f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a5ed82f035549f108343a03613f51703f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#af120d89e856a5a6bdf8d96a33bb67da4) process.
  * The time-out is set for each of the underlying code readers that run in parallel. And so it also limits the total [`ECodeReader::Read`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#ac4d131d9f3d4f049ec792cb09e748a0f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a5ed82f035549f108343a03613f51703f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#af120d89e856a5a6bdf8d96a33bb67da4) processing time.
* Use the property [`ECodeReader::GetMaxNumCodesPerType`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#a19e2c5f1c7cf68585c2b6c4977959b0d) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a877a54ca991ba17f0690dbeaf95938df) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#a88c46efd9fc1a01a27335ecbffe580da) to set the maximum number of codes to search for each type.
* Use the following properties to set the settings specific to one of the supported types of code:
  * [`ECodeReader::GetBarCodeReader`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#a03962b952b723a0e182d0b64e80b61e6) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a9376446f7d9469dd9b2406ca330c9e8f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#a39a9f0ecce3331f883948e6d9f8e3aa7) retrieves the underlying [`EBarCodeReader`](../../doxygen_cpp/classeVision_1_1EasyBarCode2_1_1EBarCodeReader.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EasyBarCode2_1_1EBarCodeReader.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EasyBarCode2_1_1EBarCodeReader.html) instance.

    #### SEE ALSO
    For more information about the relevant settings, refer to the documentation of [EasyBarCode](easybarcode/easybarcode2.html.md).
  * [`ECodeReader::GetMatrixCodeReader`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#a4660198c7b0d568ab9c812d4c7c8ac2b) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#ac139d0fc15cf6666881a1f3486a7455e) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#ac0e604e959bd35ad2554bfb4e30a273d) retrieves the underlying [`EMatrixCodeReader`](../../doxygen_cpp/classeVision_1_1EasyMatrixCode2_1_1EMatrixCodeReader.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EasyMatrixCode2_1_1EMatrixCodeReader.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EasyMatrixCode2_1_1EMatrixCodeReader.html) instance.

    #### SEE ALSO
    For more information about the relevant settings, refer to the documentation of [EasyMatrixCode](easymatrixcode2/using_easymatrixcode2.html.md#mxc2-read-parameters).
  * [`ECodeReader::GetQRCodeReader`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#adfa36ca2bed4996e3014c8c2dbeb1452) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#ae207774cdbf085e5aaec57cc95caff25) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#a21570186970fe59483fae6b13f8f6483) retrieves the underlying [`EQRCodeReader`](../../doxygen_cpp/classeVision_1_1EQRCodeReader.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EQRCodeReader.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EQRCodeReader.html) instance.

    #### SEE ALSO
    For more information about the relevant settings, refer to the documentation of [EasyQRCode](easyqrcode/using_easyqrcode.html.md#easyqrcode-reading-parameters).

<a id="ecodereader-component"></a>

## Code Specific Results

The [`ECodeReader::Read`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#ac4d131d9f3d4f049ec792cb09e748a0f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a5ed82f035549f108343a03613f51703f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#af120d89e856a5a6bdf8d96a33bb67da4) method returns a vector of [`ECode`](../../doxygen_cpp/classeVision_1_1ECode.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html), from these:

* Use the property [`ECode::GetDecodedString`](../../doxygen_cpp/classeVision_1_1ECode.html#ac85cb88a6dbd8283e1274cb53cbdfecf) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#a9af2f11e45081455eea4f4241eaafe9a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#a0349c8feddaf3759fe2566042c0f2319) to retrieve the contents of the code.
* Use the property [`ECode::GetIsGS1`](../../doxygen_cpp/classeVision_1_1ECode.html#ae606af734ca68121bd5c7e6c66084ab8) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#a0d7d6e92f52da4f849eab8f6df1d589a) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#a300afdf1d3c0f118d4523ed1fbb289d0) to query whether the code uses the GS1 standard.
* Use the method [`ECode::DrawPosition`](../../doxygen_cpp/classeVision_1_1ECode.html#ac3fafaeab6200191d455519a7e76f1dd) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#a477ce22e23906089bd7e03a57365a977) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#add983bc8b1225d58b7e733fe5c21fdc0) to draw the position of the code.
* Use the property [`ECode::GetCodeType`](../../doxygen_cpp/classeVision_1_1ECode.html#ab498f9732cd3dfb2de9500410d38bfc3) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#a6168a8f5039a23ac9b615ca0925ff523) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#a1f1f4263a1efe22bac0bfc959790246d) if you need to know the specific type of the code.
* Use the following properties to retrieve the information specific to a given type of code from an [`ECode`](../../doxygen_cpp/classeVision_1_1ECode.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html) instance:
  * [`ECode::GetBarCode`](../../doxygen_cpp/classeVision_1_1ECode.html#aa3c176073031a496e4e766034ec331c0) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#a8a0eea240e29147d1f1d825bea3fec48) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#abbf0748955d0ce4bd90790e79cee15c7) returns an [`EBarCode`](../../doxygen_cpp/classeVision_1_1EasyBarCode2_1_1EBarCode.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EasyBarCode2_1_1EBarCode.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EasyBarCode2_1_1EBarCode.html) object.

    #### SEE ALSO
    For more information, refer to the documentation of [EBarCode](easybarcode/easybarcode2.html.md#easybarcode2-ebarcode-contents).
  * [`ECode::GetMatrixCode`](../../doxygen_cpp/classeVision_1_1ECode.html#a8ae34d6db9a4142a20af64ec0c26d1e2) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#aef899fdd8f9c9edc5c0128a14ed0fa87) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#ae5f59acd8fcf673822c0e7f6d99deb28) returns a [`EMatrixCode`](../../doxygen_cpp/classeVision_1_1EasyMatrixCode2_1_1EMatrixCode.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EasyMatrixCode2_1_1EMatrixCode.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EasyMatrixCode2_1_1EMatrixCode.html) object.

    #### SEE ALSO
    For more information, refer to the documentation of [EMatrixCode](easymatrixcode2/using_easymatrixcode2.html.md#mxc2-ematrixcode-contents).
  * [`ECode::GetQRCode`](../../doxygen_cpp/classeVision_1_1ECode.html#a9daa9dd9e2ce532cda4b9760b3fae7eb) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECode.html#abe6929bc001eaa13a9e68eaf9af836ad) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECode.html#a7fa8044e6f414f8fb8f1f119d919e7c6) returns an [`EQRCode`](../../doxygen_cpp/classeVision_1_1EQRCode.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EQRCode.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EQRCode.html) object.

    #### SEE ALSO
    For more information, refer to the documentation of [EQRCode](easyqrcode/using_easyqrcode.html.md#easyqrcode-contents).

<a id="ecodereader-multithreading"></a>

## Multithreading

**ECodeReader** always parallelizes the location and the decoding of the different types of code.

* [`Easy::SetMaxNumberOfProcessingThreads`](../../doxygen_cpp/classeVision_1_1Easy.html#a07daba7dfbeff40db5e1d9e4404d4722) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1Easy.html#ae729364026373ca376e818d4b82cd978) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1Easy.html#ae819b646aea6778997c6155442a0ccee) has no effect on this behavior.
* However, [`Easy::SetMaxNumberOfProcessingThreads`](../../doxygen_cpp/classeVision_1_1Easy.html#a07daba7dfbeff40db5e1d9e4404d4722) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1Easy.html#ae729364026373ca376e818d4b82cd978) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1Easy.html#ae819b646aea6778997c6155442a0ccee) has the intended effect on the underlying code readers and speeds up the whole process.

<a id="ecodereader-grid"></a>

## Reading Using a Grid

If the codes in the images are arranged in a regular grid-like fashion:

* Use the dedicated method overloads [`ECodeReader::Read`](../../doxygen_cpp/classeVision_1_1ECodeReader.html#ac4d131d9f3d4f049ec792cb09e748a0f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeReader.html#a5ed82f035549f108343a03613f51703f) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeReader.html#af120d89e856a5a6bdf8d96a33bb67da4) that return [`ECodeGrid`](../../doxygen_cpp/classeVision_1_1ECodeGrid.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeGrid.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeGrid.html) objects to improve the reliability and the speed of the reading.
* Use the methods [`EGrid::SetEnableCell`](../../doxygen_cpp/classeVision_1_1EGrid.html#aba771f188948f660da2c0194a9b58a3f) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EGrid.html#a1fd0da028d375583b1e88dcce0773be4) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EGrid.html#a8b512a41cd91f259e36ecbb171d78865), [`EGrid::SetEnableRow`](../../doxygen_cpp/classeVision_1_1EGrid.html#a3844f5b8b179aeaf4a2126498caf2f76) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EGrid.html#a773b4e6991849b0ecc1ba54fd3cbcacc) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EGrid.html#a39048b6eb0c0ffd668612f477c310d76), [`EGrid::SetEnableColumn`](../../doxygen_cpp/classeVision_1_1EGrid.html#a38b2cd477e372de59eb97368b9e99bb8) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EGrid.html#a58a6e9901b3fda53ee457f02a590f049) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EGrid.html#a7f3a7e831554b929a05d5aeb4a78f1ee) or [`EGrid::SetEnableAll`](../../doxygen_cpp/classeVision_1_1EGrid.html#a94d5c95f83523c96f7f3ce4183117803) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1EGrid.html#af176f6ab91c3a5b439526df7442d0ed6) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1EGrid.html#a6ab6b2c8a001ead2c95b6c6662ac61dc) to disable the processing of cells that you know do not contain any code.
* Use the method [`ECodeGrid::GetResults`](../../doxygen_cpp/classeVision_1_1ECodeGrid.html#a4c01d294b85de8c2958d0d03cbba8925) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeGrid.html#ab75a32f4b977f57f3e6cb1e6cafa9974) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeGrid.html#a3019c50188df64051d53799dbd380362) of the returned [`ECodeGrid`](../../doxygen_cpp/classeVision_1_1ECodeGrid.html) [<sub>.NET</sub>](../../doxygen_cs/classeVision_1_1ECodeGrid.html) [<sub>Python</sub>](../../doxygen_python/classeVision_1_1ECodeGrid.html) object to retrieve the codes read in each cell of the defined grid.

![image](assets/images/ecodereader/grid.webp)

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

## Quick Links

Code snippets for **ECodeReader**.

All the code symbologies read by the text and code reading libraries.

Assess the printing quality of your bar, data matrix and QR codes.
