Tuning the Search Parameters

This code snippet shows how to read a QR code and retrieve the decoded data after setting a number of search parameters.

C++

#include <eVision/EasyQRCode/EQRCodeReader.h>
using namespace eVision;

// Image constructor
EImageBW8 srcImage;

// QR code reader constructor
EQRCodeReader reader;

// ...

// Set the search parameters
reader.SetMaximumVersion(7);
reader.SetMinimumIsotropy(0.9f);

// Set the searched models
std::vector<EQRCodeModel> models;
models.push_back(EQRCodeModel_Model2);
reader.SetSearchedModels(models);

// Read
std::vector<EQRCode> qrCodes = reader.Read(srcImage);

// Retrieve the decoded string in best guess mode of the first QR code found
std::string decodedString = qrCodes[0].GetDecodedString(EByteInterpretationMode_Auto);

C#

using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();

// QR code reader constructor
EQRCodeReader reader = new EQRCodeReader();

// ...

// Set the search parameters
reader.MaximumVersion = 7;
reader.MinimumIsotropy = 0.9f;

// Set the searched models
reader.SearchedModels = new EQRCodeModel[] { EQRCodeModel.Model2 };

// Read
EQRCode[] qrCodes = reader.Read(srcImage);

// Retrieve the decoded string in best guess mode of the first QR code found
string decodedString = qrCodes[0].GetDecodedString(EByteInterpretationMode.Auto);

Python

import eVision
# Image constructor
src_image = eVision.EImageBW8()

# QR code reader constructor
reader = eVision.EQRCodeReader()

# ...

# Set the search parameters
reader.MaximumVersion = 7
reader.MinimumIsotropy = 0.9

# Set the searched models
models = []
models.append(eVision.EQRCodeModel.Model2)
reader.SearchedModels = models

# Read
qr_codes = reader.Read(src_image)

# Retrieve the decoded string in best guess mode of the first QR code found
decoded_string = qr_codes[0].GetDecodedString(eVision.EByteInterpretationMode.Auto)