Retrieving the Decoded Data (Advanced)¶
This code snippet shows how to read a QR code and retrieve its coding mode, the raw bit stream and the data part by part.
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 stream of the first QR code found
EQRCodeDecodedStream stream = qrCodes[0].GetDecodedStream();
// Retrieve the coding mode and the raw bit stream of the first QR code found
EQRCodeCodingMode codingMode = stream.GetCodingMode();
std::vector<uint8_t> bitstream = stream.GetRawBitstream();
// Retrieve the encoding and the decoded data of each part of the first QR code found
std::vector<EQRCodeDecodedStreamPart> parts = stream.GetDecodedStreamParts();
for (unsigned int i = 0; i < parts.size(); ++i)
{
// Retrieve encoding
EQRCodeEncoding encoding = parts[i].GetEncoding();
// Retrieve the decoded data
std::vector<uint8_t> decodedData = parts[i].GetDecodedData();
// Interpret the decoded data based on the retrieved encoding
}
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 stream of the first QR code found
EQRCodeDecodedStream stream = qrCodes[0].DecodedStream;
// Retrieve the coding mode and the raw bit stream of the first QR code found
EQRCodeCodingMode codingMode = stream.CodingMode;
byte[] bitstream = stream.RawBitstream;
// Retrieve the encoding and the decoded data of each part of the first QR code found
EQRCodeDecodedStreamPart[] parts = stream.DecodedStreamParts;
for (uint i = 0; i < parts.Length; ++i)
{
// Retrieve encoding
EQRCodeEncoding encoding = parts[i].Encoding;
// Retrieve the decoded data
byte[] decodedData = parts[i].DecodedData;
// Interpret the decoded data based on the retrieved encoding
}
Python¶
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# QR code reader constructor
reader = eVision.EQRCodeReader()
# ...
# Read
qr_codes = reader.Read(src_image)
# Retrieve the data stream of the first QR code found
stream = qr_codes[0].DecodedStream
# Retrieve the coding mode and the raw bit stream of the first QR code found
coding_mode = stream.CodingMode
bitstream = stream.RawBitstream
# Retrieve the encoding and the decoded data of each part of the first QR code found
parts = stream.DecodedStreamParts
for part in parts:
# Retrieve encoding
encoding = part.Encoding
# Retrieve the decoded data
decoded_data = part.DecodedData
# Interpret the decoded data based on the retrieved encoding