<a id="easymatrixcode2"></a>

# EasyMatrixCode - Reading Matrix Codes

![EasyMatrixCode](assets/images/easymatrixcode2/home_illustration.webp)

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

## Purpose

The **EasyMatrixCode** library allows to read data matrix codes in images:

* The reading is fast and robust.
* Several codes can be read in the same image.
* The processing can be limited to an `ERegion` in the image.
* Specific support is provided for codes arranged in a grid.
* The data matrix codes can be graded according to the `ISO 15415`, `ISO 29158` or `Semi T10` norms.

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

## Reading a Data Matrix Code

You can read the matrix code in an image automatically as follows:

* Create an [`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) object.
* Call the [`EMatrixCodeReader::Read`](../../../doxygen_cpp/classeVision_1_1EasyMatrixCode2_1_1EMatrixCodeReader.html#a890b23ec2a4a8396cb9c70eac513fc02) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyMatrixCode2_1_1EMatrixCodeReader.html#ad08f5fd519e6a442d9432e056833d764) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyMatrixCode2_1_1EMatrixCodeReader.html#abb1ad9145229c3dd52fe1b576099f6c6) method to return a vector of [`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).
* Each instance contains, among others, the [`string`](../../../doxygen_cpp/classeVision_1_1EasyMatrixCode2_1_1EMatrixCode.html#a57f1437adadef93d74a5c93191564a3d) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyMatrixCode2_1_1EMatrixCode.html#a10faca778b3ddcc1fe29f5a2f74e9d40) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyMatrixCode2_1_1EMatrixCode.html#ae7719ab402a6994cc374c8d901bab2b6) embedded in the data matrix code.

#### NOTE
The relevant classes of the [`EasyMatrixCode`](../../../reference_manual/text_and_code_reading/easymatrixcode-library.html.md) library are stored in the namespace `EasyMatrixCode2`. Classes outside that namespace (refered to as `EasyMatrixCode1`) are an earlier version of the **EasyMatrixCode** library, now deprecated.

### C++

```cpp
#include <eVision/EasyMatrixCode/EasyMatrixCode2/EMatrixCodeReader.h>
```

```cpp
using namespace eVision;
namespace EMC2 = eVision::EasyMatrixCode2;
// Load an image
EImageBW8 image;
image.Load("image.bmp");
// Prepare a matrix code reader
EMC2::EMatrixCodeReader reader;
// Let the reader know that there are no more than 3 codes in the image
reader.SetMaxNumCodes(3);
// Read the source image
reader.Read(image);
// Retrieve the detected codes
std::vector<EMC2::EMatrixCode> codes = reader.GetReadResults();
// Retrieve the decoded string for the first code
std::string result = codes[0].GetDecodedString();
```

### C#

```cs
using eVision;
using EMC2 = eVision.EasyMatrixCode2;
```

```cs
// Load an image
EImageBW8 image = new EImageBW8();
image.Load("image.bmp");
// Prepare a matrix code reader
EMC2.EMatrixCodeReader reader = new EMC2.EMatrixCodeReader();
// Let the reader know that there are no more than 3 codes in the image
reader.MaxNumCodes = 3;
// Read the source image
reader.Read(image);
// Retrieve the detected codes
EMC2.EMatrixCode[] codes = reader.ReadResults;
// Retrieve the decoded string for the first code
string result = codes[0].DecodedString;
```

### Python

```py
import eVision
from eVision import EasyMatrixCode2 as EMC2
# Load an image
image = eVision.EImageBW8()
image.Load("image.bmp")
# Prepare a matrix code reader
reader = EMC2.EMatrixCodeReader()
# Let the reader know that there are no more than 3 codes in the image
reader.MaxNumCodes = 3
# Read the source image
codes = reader.Read(image)
# Retrieve the decoded string for the first code
result = codes[0].DecodedString
```

<a id="easymatrixcode2-contents"></a>

## Contents

Specifications of the data matrix and **EasyMatrixCode** library.

How to use the **EasyMatrixCode** library.

How to use the first version of the **EasyMatrixCode** library, now deprecated.

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

## Quick Links

List of all Classes, Structs and Enumerations of the **EasyMatrixCode** library.

Code snippets for the **EasyMatrixCode** library.

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

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

Read bar, data matrix and QR codes using a unified interface.

#### SEE ALSO
Some **eVision Studio** samples illustrate several aspects of the **EasyMatrixCode** library:

* `Data matrix reading`: Uses **EasyMatrixCode** to read a data matrix code in an image.
* `Matrix code grid`: Uses **EasyMatrixCode** to read several data matrix codes ordered in a grid setting in an image.
