Ocean
Loading...
Searching...
No Matches
Ocean::CV::Detector::QRCodes::QRCodeBase Class Referenceabstract

Base class for QR code implementations. More...

#include <QRCodeBase.h>

Inheritance diagram for Ocean::CV::Detector::QRCodes::QRCodeBase:

Public Types

enum  CodeType : unsigned int { CT_UNDEFINED = 0u , CT_STANDARD , CT_MICRO }
 Definition of available types of codes. More...
 
enum  ErrorCorrectionCapacity : uint32_t {
  ECC_07 = 0b01u , ECC_15 = 0b00u , ECC_25 = 0b11u , ECC_30 = 0b10u ,
  ECC_DETECTION_ONLY = 5u , ECC_INVALID = uint32_t(-1)
}
 Enumeration of the levels of error correction The value of the enums correspond to the standard-defined bit sequences (2 bits long) More...
 
enum  EncodingMode : uint32_t {
  EM_NUMERIC = 0u , EM_ALPHANUMERIC , EM_BYTE , EM_KANJI ,
  EM_ECI , EM_STRUCTURED_APPEND , EM_FNC1 , EM_INVALID_ENCODING_MODE = uint32_t(-1)
}
 Definition of encoding modes. More...
 

Public Member Functions

virtual ~QRCodeBase ()=default
 Destructs a QR code instance.
 
virtual bool isValid () const =0
 Returns whether this is a valid QR code instance.
 
CodeType codeType () const
 Returns the type or variant of this code.
 
const std::vector< uint8_t > & data () const
 Returns a constant reference to the plain data of the QR code.
 
std::string dataString () const
 Return the plain data of the QR code as a string, if possible.
 
const std::vector< uint8_t > & modules () const
 Returns the modules of this QR code The modules are stored in a vector and will have modulesPerSide() * modulesPerSide() elements (row-wise order)
 
EncodingMode encodingMode () const
 Returns the encoding mode of the QR code.
 
ErrorCorrectionCapacity errorCorrectionCapacity () const
 Returns the error correction capacity of the QR code.
 
unsigned int version () const
 Returns the version of the QR code.
 
virtual std::string versionString () const
 Returns the version of the QR code as a string.
 
virtual unsigned int modulesPerSide () const =0
 Returns the number of modules per side of the QR code.
 
bool isSame (const QRCodeBase &otherCode, const bool ignoreModules) const
 Checks if another code is identical to this one.
 
bool operator== (const QRCodeBase &otherCode) const
 Checks for equality with another QR code Two QR codes are equal iff they store identical data, use the same configuration, and have identical modules.
 
bool operator!= (const QRCodeBase &otherCode) const
 Checks for inequality with another QR code.
 

Static Public Member Functions

static std::string translateEncodingMode (const EncodingMode encodingMode)
 Translates an encoding mode enum into a human-readable string.
 
static std::string translateErrorCorrectionCapacity (const ErrorCorrectionCapacity errorCorrectionCapacity)
 Translates an error correction capacity enum into a human-readable string.
 
static unsigned int getErrorCorrectionCapacityValue (const ErrorCorrectionCapacity errorCorrectionCapacity)
 Returns the integer value of an error correction capacity.
 
static std::string translateCodeType (const CodeType codeType)
 Translate the code type into a human-readable string.
 

Protected Member Functions

 QRCodeBase ()=default
 Creates an invalid QR code instance.
 
 QRCodeBase (const CodeType codeType, std::vector< uint8_t > &&data, const EncodingMode encodingMode, const ErrorCorrectionCapacity errorCorrectionCapacity, std::vector< uint8_t > &&modules, const unsigned int version)
 Creates an QR code instance.
 
 QRCodeBase (const QRCodeBase &otherCode)=default
 Copy constructor.
 
QRCodeBaseoperator= (const QRCodeBase &otherCode)=default
 Copy assignment operator.
 

Protected Attributes

CodeType codeType_ = CT_UNDEFINED
 The variant of this QR code.
 
std::vector< uint8_t > data_
 The plain data.
 
EncodingMode encodingMode_ = EM_INVALID_ENCODING_MODE
 The encoding mode that was used to generate this QR code.
 
ErrorCorrectionCapacity errorCorrectionCapacity_ = ECC_INVALID
 The error correction capacity that was used to generated this QR code.
 
std::vector< uint8_t > modules_
 The modules of the QR code that store the data.
 
unsigned int version_ = 0u
 The version of the QR code.
 

Detailed Description

Base class for QR code implementations.

Member Enumeration Documentation

◆ CodeType

Definition of available types of codes.

Enumerator
CT_UNDEFINED 

Default value of undefined or invalid code types.

CT_STANDARD 

Indicates a standard QR codes.

CT_MICRO 

Indicates a Micro QR codes.

◆ EncodingMode

Definition of encoding modes.

Enumerator
EM_NUMERIC 

Mode that supports digits 0-9.

EM_ALPHANUMERIC 

Mode that supports A-Z, 0-9 and a few others, cf. ALPHANUMERIC_CHARSET

EM_BYTE 

Mode that represents data as a sequence of bytes.

EM_KANJI 

Mode that handles Kanji characters in accordance with the Shift JIS system based on JIS X 0208.

EM_ECI 

Mode that allows the output data stream to have interpretations different from that of the default character set.

EM_STRUCTURED_APPEND 

Structured Append mode is used to split the encodation of the data from a message over a number of QR Code symbols.

EM_FNC1 

Mode that is used for messages containing data formatted either in accordance with the UCC/EAN Application Identifiers standard.

EM_INVALID_ENCODING_MODE 

Indicator for an invalid encoding mode.

◆ ErrorCorrectionCapacity

Enumeration of the levels of error correction The value of the enums correspond to the standard-defined bit sequences (2 bits long)

Enumerator
ECC_07 

Indicates that 7% of the modules reserved error correction.

ECC_15 

Indicates that 15% of the modules reserved error correction.

ECC_25 

Indicates that 25% of the modules reserved error correction.

ECC_30 

Indicates that 30% of the modules reserved error correction.

ECC_DETECTION_ONLY 

Indicates that the capacity is limited to error detection only (used only by Micro QR Code version M1)

ECC_INVALID 

Indicator for an invalid error correction capacity.

Constructor & Destructor Documentation

◆ ~QRCodeBase()

virtual Ocean::CV::Detector::QRCodes::QRCodeBase::~QRCodeBase ( )
virtualdefault

Destructs a QR code instance.

◆ QRCodeBase() [1/3]

Ocean::CV::Detector::QRCodes::QRCodeBase::QRCodeBase ( )
protecteddefault

Creates an invalid QR code instance.

◆ QRCodeBase() [2/3]

Ocean::CV::Detector::QRCodes::QRCodeBase::QRCodeBase ( const CodeType  codeType,
std::vector< uint8_t > &&  data,
const EncodingMode  encodingMode,
const ErrorCorrectionCapacity  errorCorrectionCapacity,
std::vector< uint8_t > &&  modules,
const unsigned int  version 
)
inlineexplicitprotected

Creates an QR code instance.

Parameters
codeTypeThe type or variant of this codes, must not be CT_UNDEFINED.
dataThe plain data of this QR code, must be valid
encodingModeThe encoding mode that was used to encode the data, must not be EM_INVALID_ENCODING_MODE
errorCorrectionCapacityThe error correction capacity that was used to generate this QR code, must not be ECC_INVALID
modulesThe modules of the QR code that store the data, must be valid
versionThe version of the QR code, range: [1, 40]
See also
QRCodeEncoder, QRCodeDecoder

◆ QRCodeBase() [3/3]

Ocean::CV::Detector::QRCodes::QRCodeBase::QRCodeBase ( const QRCodeBase otherCode)
inlineprotecteddefault

Copy constructor.

Member Function Documentation

◆ codeType()

QRCodeBase::CodeType Ocean::CV::Detector::QRCodes::QRCodeBase::codeType ( ) const
inline

Returns the type or variant of this code.

Returns
The code type

◆ data()

const std::vector< uint8_t > & Ocean::CV::Detector::QRCodes::QRCodeBase::data ( ) const
inline

Returns a constant reference to the plain data of the QR code.

Returns
The constant reference
See also
dataAlphanumeric()

◆ dataString()

std::string Ocean::CV::Detector::QRCodes::QRCodeBase::dataString ( ) const
inline

Return the plain data of the QR code as a string, if possible.

Returns
The data as string if the encoding mode is EM_NUMERIC or EM_ALPHANUMERIC, otherwise an empty string is returned
See also
data()

◆ encodingMode()

QRCodeBase::EncodingMode Ocean::CV::Detector::QRCodes::QRCodeBase::encodingMode ( ) const
inline

Returns the encoding mode of the QR code.

Returns
The encoding mode

◆ errorCorrectionCapacity()

QRCodeBase::ErrorCorrectionCapacity Ocean::CV::Detector::QRCodes::QRCodeBase::errorCorrectionCapacity ( ) const
inline

Returns the error correction capacity of the QR code.

Returns
The error correction capacity

◆ getErrorCorrectionCapacityValue()

unsigned int Ocean::CV::Detector::QRCodes::QRCodeBase::getErrorCorrectionCapacityValue ( const ErrorCorrectionCapacity  errorCorrectionCapacity)
inlinestatic

Returns the integer value of an error correction capacity.

Parameters
errorCorrectionCapacityThe error correction capacity that will be converted into an integer
Returns
The value of the error correction capacity

◆ isSame()

bool Ocean::CV::Detector::QRCodes::QRCodeBase::isSame ( const QRCodeBase otherCode,
const bool  ignoreModules 
) const
inline

Checks if another code is identical to this one.

Parameters
otherCodeThe code that will be compared against for identity, must be valid.
ignoreModulesTrue, identical modules in both codes will not be required, otherwise they will.
Returns
True if both codes are identical, otherwise false.

◆ isValid()

virtual bool Ocean::CV::Detector::QRCodes::QRCodeBase::isValid ( ) const
inlinepure virtual

Returns whether this is a valid QR code instance.

Returns
True if this is a valid QR code instance, otherwise false

Implemented in Ocean::CV::Detector::QRCodes::MicroQRCode, and Ocean::CV::Detector::QRCodes::QRCode.

◆ modules()

const std::vector< uint8_t > & Ocean::CV::Detector::QRCodes::QRCodeBase::modules ( ) const
inline

Returns the modules of this QR code The modules are stored in a vector and will have modulesPerSide() * modulesPerSide() elements (row-wise order)

Returns
The vector modules

◆ modulesPerSide()

virtual unsigned int Ocean::CV::Detector::QRCodes::QRCodeBase::modulesPerSide ( ) const
inlinepure virtual

Returns the number of modules per side of the QR code.

Returns
The number of modules per side

Implemented in Ocean::CV::Detector::QRCodes::MicroQRCode, and Ocean::CV::Detector::QRCodes::QRCode.

◆ operator!=()

bool Ocean::CV::Detector::QRCodes::QRCodeBase::operator!= ( const QRCodeBase otherCode) const
inline

Checks for inequality with another QR code.

Returns
True if both QR codes are not equal, otherwise false

◆ operator=()

QRCodeBase & Ocean::CV::Detector::QRCodes::QRCodeBase::operator= ( const QRCodeBase otherCode)
inlineprotecteddefault

Copy assignment operator.

◆ operator==()

bool Ocean::CV::Detector::QRCodes::QRCodeBase::operator== ( const QRCodeBase otherCode) const
inline

Checks for equality with another QR code Two QR codes are equal iff they store identical data, use the same configuration, and have identical modules.

Returns
True if both QR codes are equal, otherwise false

◆ translateCodeType()

std::string Ocean::CV::Detector::QRCodes::QRCodeBase::translateCodeType ( const CodeType  codeType)
inlinestatic

Translate the code type into a human-readable string.

Parameters
codeTypeThe code type that will be translated into a human-readable string
Returns
The human-readable string

◆ translateEncodingMode()

std::string Ocean::CV::Detector::QRCodes::QRCodeBase::translateEncodingMode ( const EncodingMode  encodingMode)
inlinestatic

Translates an encoding mode enum into a human-readable string.

Parameters
encodingModeThe encoding mode that will be converted into a string
Returns
The translated encoding mode

◆ translateErrorCorrectionCapacity()

std::string Ocean::CV::Detector::QRCodes::QRCodeBase::translateErrorCorrectionCapacity ( const ErrorCorrectionCapacity  errorCorrectionCapacity)
inlinestatic

Translates an error correction capacity enum into a human-readable string.

Parameters
errorCorrectionCapacityThe error correction capacity that will be converted into a string
Returns
The translated error correction capacity

◆ version()

unsigned int Ocean::CV::Detector::QRCodes::QRCodeBase::version ( ) const
inline

Returns the version of the QR code.

Returns
The version number

◆ versionString()

std::string Ocean::CV::Detector::QRCodes::QRCodeBase::versionString ( ) const
inlinevirtual

Returns the version of the QR code as a string.

Returns
The version string

Reimplemented in Ocean::CV::Detector::QRCodes::MicroQRCode.

Field Documentation

◆ codeType_

CodeType Ocean::CV::Detector::QRCodes::QRCodeBase::codeType_ = CT_UNDEFINED
protected

The variant of this QR code.

◆ data_

std::vector<uint8_t> Ocean::CV::Detector::QRCodes::QRCodeBase::data_
protected

The plain data.

◆ encodingMode_

EncodingMode Ocean::CV::Detector::QRCodes::QRCodeBase::encodingMode_ = EM_INVALID_ENCODING_MODE
protected

The encoding mode that was used to generate this QR code.

◆ errorCorrectionCapacity_

ErrorCorrectionCapacity Ocean::CV::Detector::QRCodes::QRCodeBase::errorCorrectionCapacity_ = ECC_INVALID
protected

The error correction capacity that was used to generated this QR code.

◆ modules_

std::vector<uint8_t> Ocean::CV::Detector::QRCodes::QRCodeBase::modules_
protected

The modules of the QR code that store the data.

◆ version_

unsigned int Ocean::CV::Detector::QRCodes::QRCodeBase::version_ = 0u
protected

The version of the QR code.


The documentation for this class was generated from the following file: