CVB++ 15.0
Decoder Class Referencefinal

Class for barcode decoding. More...

#include <decl_decoder.hpp>

Public Member Functions

std::vector< ResultExecute (const ImagePlane &plane, Rect< int > aoi)
 Performs the barcode decoding. More...
 
std::vector< ResultExecute (const ImagePlane &plane)
 Performs the barcode decoding. More...
 
template<Symbology SYM>
Config::Mapper< SYM >::Type & Config ()
 Retrieves the configuration object for a specific barcode symbology.
More...
 
void SetEnableBasicInkjetDPM (bool value)
 Enables or disables the reading of Basic Inkjet DPM (Direct Part Marking) codes. More...
 
bool EnabledBasicInkjetDPM () const
 Checks whether the Basic Inkjet DPM mode is enabled. More...
 

Static Public Member Functions

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

Detailed Description

Class for barcode decoding.

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

To decode an image containing a supported barcode, 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 Barcode::Symbology template. All supported barcode types are enumerated in the enum class Barcode::Symbology.

After configuring the decoder, load an image containing the barcode(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/barcode/barcode.hpp>
using namespace Cvb::Barcode;
// Create a decoder.
auto decoder = Decoder::Create();
// Retrieve the configuration object for a specific barcode 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_barcode.bmp"));
auto results = decoder->Execute(image->Plane(0));
// Display results.
std::cout << results.size() << " barcode(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:32
Namespace for all barcode decoding functionalities.
Definition: decl_config_2d_barcodes.hpp:10
@ DataMatrix
Data Matrix.

Member Function Documentation

◆ Config()

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

Retrieves the configuration object for a specific barcode symbology.

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

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

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

decoder->Config<Cvb::Barcode::Symbology::DataMatrix>().Enable().SetMirroring(true);
Template Parameters
SYMThe barcode 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.

◆ EnabledBasicInkjetDPM()

bool EnabledBasicInkjetDPM ( ) const
inline

Checks whether the Basic Inkjet DPM mode is enabled.

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

◆ Execute() [1/2]

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

Performs the barcode decoding.

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

◆ Execute() [2/2]

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

Performs the barcode decoding.

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

◆ SetEnableBasicInkjetDPM()

void SetEnableBasicInkjetDPM ( 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.