CVB++ 15.0

Class for decoding. More...

#include <decl_decoder.hpp>

Public Member Functions

std::vector< ResultExecute (const ImagePlane &plane, const Rect< int > &aoi)
 Performs the decoding.
 
std::vector< ResultExecute (const ImagePlane &plane)
 Performs the decoding.
 
template<Symbology SYM>
Config::Mapper< SYM >::Type & Config ()
 Retrieves the configuration object for a specific symbology.
 
void SetBasicInkjetDPMEnabled (bool value)
 Enables or disables the reading of Basic Inkjet DPM (Direct Part Marking) codes.
 
bool IsBasicInkjetDPMEnabled () const
 Checks whether the Basic Inkjet DPM mode is enabled.
 
void SetAllCommon1DCodesEnabled (bool value)
 Enables all common 1D codes.
 
bool AllCommon1DCodesEnabled () const
 Checks whether all common 1D codes are enabled.
 
void SetAll2DCodesEnabled (bool value)
 Enables all 2D codes.
 
bool All2DCodesEnabled () const
 Checks whether all 2D codes are enabled.
 
void SetCustomPerformance (CustomPerformance value)
 Sets the custom image processing method used to optimize decoding robustness and performance.
 
CodeReader::CustomPerformance CustomPerformance () const
 Retrieves the custom image processing method used to optimize decoding robustness and performance.
 
void SetDetectorDensity (int value)
 Sets the detector density to control the search aggressiveness for small codes.
 
int DetectorDensity () const
 Retrieves the detector density to control the search aggressiveness for small codes.
 

Static Public Member Functions

static std::unique_ptr< DecoderCreate ()
 Creates and returns a new Decoder instance.
 

Detailed Description

Class for decoding.

This class provides the core functionality for detecting and decoding codes in images. Each codes type can be configured using its corresponding configuration class.

To decode an image containing a supported codes, start by creating a decoder. You can configure your decoder using the member function Decoder::Config(), which returns a reference to the desired configuration class. The configuration class is specified by the CodeReader::Symbology template. All supported codes types are enumerated in the enum class CodeReader::Symbology.

After configuring the decoder, load an image containing the codes(s) and execute the decoding process. The following code snippet demonstrates how to decode an image containing Data Matrix and QR codes:

#include <iostream>
#include <cvb/image.hpp>
#include <cvb/code_reader/code_reader.hpp>
using namespace Cvb::CodeReader;
// Create a decoder.
auto decoder = Decoder::Create();
// Retrieve the configuration object for a specific symbology.
auto& config = decoder->Config<Symbology::DataMatrix>();
// Enable decoding for the selected symbology and configure additional (optional) parameters.
config.Enable().SetPolarity(Config::Polarity::DarkOnLight);
// Alternatively, the configuration can be performed in a more concise manner:
decoder->Config<Symbology::QR>().Enable().SetPolarity(Config::Polarity::DarkOnLight);
// Load the image and decode.
auto image = Cvb::Image::Load(CVB_LIT("your_image_with_codes.bmp"));
auto results = decoder->Execute(image->Plane(0));
// Display results.
std::cout << results.size() << " codes(s) found.\n";
for (int i = 0; i < results.size(); i++)
{
std::cout << results[i].Data().c_str() << "\n";
}
static std::unique_ptr< Decoder > Create()
Creates and returns a new Decoder instance.
Definition detail_decoder.hpp:22
static std::unique_ptr< Image > Load(const String &fileName)
Loads an image with the given file name.
Definition detail_image.hpp:25
@ DarkOnLight
Definition decl_config_base.hpp:186
Namespace for all decoding functionalities.
Definition decl_config_2d_codes.hpp:10
@ QR
QR code.
Definition decl_config_base.hpp:47
@ DataMatrix
Data Matrix.
Definition decl_config_base.hpp:42

Member Function Documentation

◆ All2DCodesEnabled()

bool All2DCodesEnabled ( ) const
inline

Checks whether all 2D codes are enabled.

Returns
true if all 2D codes are enabled, false otherwise.

◆ AllCommon1DCodesEnabled()

bool AllCommon1DCodesEnabled ( ) const
inline

Checks whether all common 1D codes are enabled.

Returns
true if all common 1D codes are enabled, false otherwise.

◆ Config()

template<Symbology SYM>
Config::Mapper< SYM >::Type & Config ( )
inline

Retrieves the configuration object for a specific symbology.

Use this function to access the configuration settings for a particular symbology. After creating a decoder, you can obtain the desired configuration object as shown below:

auto &config = decoder->Config<Cvb::CodeReader::Symbology::DataMatrix>();
config.Enable();

Alternatively, you can utilize the fluent interface pattern for seamless configuration:

decoder->Config<Cvb::CodeReader::Symbology::DataMatrix>().Enable().SetMirroring(true);
Template Parameters
SYMThe symbology for which the configuration is retrieved.
Returns
A reference to the configuration object corresponding to the specified symbology.

◆ Create()

std::unique_ptr< Decoder > Create ( )
inlinestatic

Creates and returns a new Decoder instance.

Returns
A std::unique_ptr pointing to the newly created Decoder object.

◆ CustomPerformance()

Retrieves the custom image processing method used to optimize decoding robustness and performance.

Returns
The configured image processing method.

◆ DetectorDensity()

int DetectorDensity ( ) const
inline

Retrieves the detector density to control the search aggressiveness for small codes.

For detals refer to SetDetectorDensity.

Returns
Value for detector densitiy.

◆ Execute() [1/2]

std::vector< Result > Execute ( const ImagePlane & plane)
inline

Performs the decoding.

Up to 256 codes can be detected using this function.

Parameters
planeThe image plane containing the code(s) to be decoded.
Returns
A vector of Result objects containing the decoded decoded data.

◆ Execute() [2/2]

std::vector< Result > Execute ( const ImagePlane & plane,
const Rect< int > & aoi )
inline

Performs the decoding.

For further details see function Execute(const ImagePlane &).

Parameters
planeThe image plane containing the code(s) to be decoded.
aoiThe area of interest within the image where the decoding operation will be performed.
Returns
A vector of Result objects containing the decoded decoded data.

◆ IsBasicInkjetDPMEnabled()

bool IsBasicInkjetDPMEnabled ( ) const
inline

Checks whether the Basic Inkjet DPM mode is enabled.

Returns
true if the Basic Inkjet DPM mode is enabled, false otherwise.

◆ SetAll2DCodesEnabled()

void SetAll2DCodesEnabled ( bool value)
inline

Enables all 2D codes.

Parameters
valueSet to true to enable all 2D codes.

◆ SetAllCommon1DCodesEnabled()

void SetAllCommon1DCodesEnabled ( bool value)
inline

Enables all common 1D codes.

Enables Code128, Code39, UPCA, UPCE, EAN8, EAN13, Interleaved2of5, Code93, GS1DataBar codes.

Parameters
valueSet to true to enable all common 1D codes.

◆ SetBasicInkjetDPMEnabled()

void SetBasicInkjetDPMEnabled ( bool value)
inline

Enables or disables the reading of Basic Inkjet DPM (Direct Part Marking) codes.

This setting applies exclusively to DPM codes. Enabling Basic Inkjet DPM allows for the reading of low-quality inkjet images.

Parameters
valueSet to true to enable Basic Inkjet DPM, false otherwise.

◆ SetCustomPerformance()

void SetCustomPerformance ( CodeReader::CustomPerformance value)
inline

Sets the custom image processing method used to optimize decoding robustness and performance.

The default setting is CustomPerformance::None.

Parameters
valueValue for image processing method.

◆ SetDetectorDensity()

void SetDetectorDensity ( int value)
inline

Sets the detector density to control the search aggressiveness for small codes.

Lower values increase the robustness when decoding small or poorly printed 2D codes, but may result in longer decoding times. Higher values reduce decoding time, but may decrease robustness for small codes. The default value is 3.

Parameters
valueDetector density value between 1 and 4 (inclusive).