Learning a Data Matrix Code Code Snippet

This code snippet shows how to learn a given data matrix code type (except its flipping status), perform the reading and retrieve the decoded string.

C++

#include <eVision/EasyMatrixCode/EasyMatrixCode1/EMatrixCodeReader.h>
using namespace eVision;
// Images constructor
EImageBW8 model;
EImageBW8 srcImage;
// Matrix code reader constructor
EMatrixCodeReader reader;
// Matrix code constructor
EMatrixCode mxCode;
// String for the decoded information
std::string result;
// ...
// Tell the reader not to take the flipping into account when learning
reader.SetLearnMaskElement(ELearnParam_Flipping, false);
// Learn the model
reader.Learn(model);
// Read the source image
mxCode = reader.Read(srcImage);
// Retrieve the decoded string
result = mxCode.GetDecodedString();

C#

using eVision;
// Images constructor
EImageBW8 model = new EImageBW8();
EImageBW8 srcImage = new EImageBW8();
// Matrix code reader constructor
EMatrixCodeReader reader = new EMatrixCodeReader();
// Matrix code constructor
EMatrixCode mxCode = new EMatrixCode();
// String for the decoded information
string result;
// ...
// Tell the reader not to take the flipping into account when learning
reader.SetLearnMaskElement(ELearnParam.Flipping, false);
// Learn the model
reader.Learn(model);
// Read the source image
mxCode = reader.Read(srcImage);
// Retrieve the decoded string
result = mxCode.DecodedString;

Python

import eVision
# Images constructor
model = eVision.EImageBW8()
src_image = eVision.EImageBW8()
# Matrix code reader constructor
reader = eVision.EMatrixCodeReader()
# Matrix code constructor
mx_code = eVision.EMatrixCode()
# ...
# Tell the reader not to take the flipping into account when learning
reader.SetLearnMaskElement(eVision.ELearnParam.Flipping, False)
# Learn the model
reader.Learn(model)
# Read the source image
mx_code = reader.Read(src_image)
# Retrieve the decoded string
result = mx_code.DecodedString