Retrieving the Decoded String (Safe)¶
This code snippet shows how to read a QR code and retrieve the decoded string.
C++¶
#include <eVision/EasyQRCode/EQRCodeReader.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// QR code reader constructor
EQRCodeReader reader;
// ...
// Read
std::vector<EQRCode> qrCodes = reader.Read(srcImage);
// Retrieve the data of the first QR code found
std::string decodedString = "";
try
{
// The QR Code can be fully decoded without user input
decodedString = qrCodes[0].GetDecodedString();
}
catch (EException exc)
{
// Handle the exception
// The QR Code cannot be fully decoded without user input
// use hexadecimal byte interpretation
decodedString = qrCodes[0].GetDecodedString(EByteInterpretationMode_Hexadecimal);
}
C#¶
using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// QR code reader constructor
EQRCodeReader reader = new EQRCodeReader();
// ...
// Read
EQRCode[] qrCodes = reader.Read(srcImage);
// Retrieve the data of the first QR code found
string decodedString = "";
try
{
// The QR Code can be fully decoded without user input
decodedString = qrCodes[0].GetDecodedString();
}
catch (EException)
{
// Handle the exception
// The QR Code cannot be fully decoded without user input
// use hexadecimal byte interpretation
decodedString = qrCodes[0].GetDecodedString(EByteInterpretationMode.Hexadecimal);
}
See also
EQRCodeReader.Read C++ Python, EQRCode.GetDecodedString C++ Python
Python¶
import eVision
src_image = eVision.EImageBW8()
# QR code reader constructor
reader = eVision.EQRCodeReader()
# ...
# Read
qr_codes = reader.Read(src_image)
# Retrieve the data of the first QR code found
decoded_string = ""
try:
# The QR Code can be fully decoded without user input
decoded_string = qr_codes[0].GetDecodedString()
except eVision.EException as exc:
# Handle the exception
# The QR Code cannot be fully decoded without user input
# use hexadecimal byte interpretation
decoded_string = qr_codes[0].GetDecodedString(eVision.EByteInterpretationMode.Hexadecimal)
See also
EQRCodeReader.Read C++ .NET, EQRCode.GetDecodedString C++ .NET