Grading a Data Matrix Code¶
This code snippet shows how to read a data matrix code and retrieve its print quality grades.
C++¶
#include <eVision/EasyMatrixCode/EasyMatrixCode2/EMatrixCodeReader.h>
using namespace eVision;
namespace EMC2 = eVision::EasyMatrixCode2;
// Load an image
EImageBW8 image;
image.Load("image.bmp");
// Prepare a matrix code reader
EMC2::EMatrixCodeReader reader;
// Tell the reader to compute grades for the read codes
reader.SetComputeGrading(true);
// Read the codes in this image
reader.Read(image);
// Retrieve the detected codes
std::vector<EMC2::EMatrixCode> codes = reader.GetReadResults();
// Retrieve the SemiT10 grades of the first code
EMatrixCodeSemiT10GradingParameters semiT10Grades = codes[0].GetSemiT10GradingParameters();
// Retrieve specific grade values
float cellDefects = semiT10Grades.CellDefects;
float symbolContrast = semiT10Grades.SymbolContrast;
float unusedErrorCorrection = semiT10Grades.UnusedErrorCorrection;
C#¶
using eVision;
using EMC2 = eVision.EasyMatrixCode2;
// Load an image
EImageBW8 image = new EImageBW8();
image.Load("image.bmp");
// Prepare a matrix code reader
EMC2.EMatrixCodeReader reader = new EMC2.EMatrixCodeReader();
// Tell the reader to compute grades for the read codes
reader.ComputeGrading = true;
// Read the codes in this image
reader.Read(image);
// Retrieve the detected codes
EMC2.EMatrixCode[] codes = reader.ReadResults;
// Retrieve the SemiT10 grades of the first code
EMatrixCodeSemiT10GradingParameters semiT10Grades = codes[0].SemiT10GradingParameters;
// Retrieve specific grade values
float cellDefects = semiT10Grades.CellDefects;
float symbolContrast = semiT10Grades.SymbolContrast;
float unusedErrorCorrection = semiT10Grades.UnusedErrorCorrection;
Python¶
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()
# Tell the reader to compute grades for the read codes
reader.ComputeGrading = True
# Read the codes in this image
codes = reader.Read(image)
# Retrieve the SemiT10 grades of the first code
semiT10Grades = codes[0].SemiT10GradingParameters
# Retrieve specific grade values
cellDefects = semiT10Grades.CellDefects
symbolContrast = semiT10Grades.SymbolContrast
unusedErrorCorrection = semiT10Grades.UnusedErrorCorrection