CVB.Net 15.0
Loading...
Searching...
No Matches

Class for decoding. More...

Inherits INativeHandle.

Public Member Functions

void Dispose ()
 IDisposable implementation.
 
GetConfig< T > ()
 Retrieves the typed configuration for the decoder.
 
IEnumerable< ResultExecute (ImagePlane imagePlane, int numMaxCodes=0)
 Executes the decoding process on the specified image plane.
 
IEnumerable< ResultExecute (ImagePlane imagePlane, Rect aoi, int numMaxCodes=0)
 Executes the decoding process on the specified image plane inside area of interest.
 

Static Public Member Functions

static Decoder Create ()
 Creates a decoder object.
 
static Decoder FromHandle (IntPtr handle)
 Creates a decoder object from a handle.
 

Protected Member Functions

virtual void Dispose (bool disposing)
 IDisposable helper function.
 

Properties

bool BasicInkjetDPMEnabled [get, set]
 Enable/disable reading of Basic Inkjet DPM (Direct Part Marking). This mode can read poor quality inkjet images.
 
CustomPerformance CustomPerformance [get, set]
 The custom image processing method to improve decoding robustness and performance.
 
int DetectorDensity [get, set]
 Sets detector density to increase or decrease the search aggressiveness for small barcodes.
 
IntPtr Handle [get]
 Native handle of the Decoder.
 
bool IsDisposed [get]
 Gets if the native handle has been disposed.
 

Events

NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
 
- Events inherited from INativeHandle
NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
 

Detailed Description

Class for decoding.

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

To decode an image containing a supported code, start by creating a decoder. You can configure your decoder using the member function Decoder.GetConfig<T> which returns a reference to the desired configuration class.

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

// Create a decoder.
using (var decoder = Decoder.Create())
{
var config = decoder.GetConfig<DataMatrix>();
// Enable decoding for the selected symbology and configure additional (optional) parameters.
config.SetEnabled(true).SetPolarity(Config.Polarity.DarkOnLight);
// Alternatively, the configuration can be performed in a more concise manner:
decoder.GetConfig<DataMatrix>().SetEnabled(true).SetPolarity(Config.Polarity.DarkOnLight);
// Load the image and decode.
using (var image = Image.FromFile("your_image_with_code.bmp"))
{
var results = decoder.Execute(image.Planes[0]);
}
}
The Common Vision Blox image.
Definition Image.cs:420
static FileImage FromFile(string fileName)
Loads an image with the given fileName .
Definition Image.cs:966
Definition CompositeCodeBase.cs:4
@ DataMatrix
Data Matrix.
Definition Result.cs:54

Member Function Documentation

◆ Create()

static Decoder Create ( )
static

Creates a decoder object.

Returns
Decoder object

◆ Dispose()

virtual void Dispose ( bool disposing)
protectedvirtual

IDisposable helper function.

Parameters
disposing

◆ Execute() [1/2]

IEnumerable< Result > Execute ( ImagePlane imagePlane,
int numMaxCodes = 0 )

Executes the decoding process on the specified image plane.

Before execution, ensure that you have configured the decoder using Decoder.GetConfig<T>. If you wish to restrict the search area, you can utilize the overloaded function Execute(ImagePlane, Rect, int).

Note
Up to 256 codes can be detected.
Parameters
imagePlaneThe image plane containing the code.
numMaxCodesMaximum number of codes to detect. 0 for no limit (up to 256).
Returns
A collection of detected codes.
Exceptions
ObjectDisposedExceptionWhen this decoder or the parent of the imagePlane is disposed.
ArgumentNullExceptionWhen parent of imagePlane is null.

◆ Execute() [2/2]

IEnumerable< Result > Execute ( ImagePlane imagePlane,
Rect aoi,
int numMaxCodes = 0 )

Executes the decoding process on the specified image plane inside area of interest.

Detailed information can be found in the description of function Execute(ImagePlane, int).

Parameters
imagePlaneThe image plane containing the code.
aoiArea of interest.
numMaxCodesMaximum number of codes to detect. 0 for no limit (up to 256).
Returns
A collection of detected codes.
Exceptions
ObjectDisposedExceptionWhen this decoder or the parent of the imagePlane is disposed.
ArgumentNullExceptionWhen parent of imagePlane is null.

◆ FromHandle()

static Decoder FromHandle ( IntPtr handle)
static

Creates a decoder object from a handle.

Parameters
handleThe decoder handle.
Returns
Decoder object

◆ GetConfig< T >()

T GetConfig< T > ( )

Retrieves the typed configuration for the decoder.

After a decoder is created with Create and before starting the decoding process with Execute, you should configure your decoder. The following code snippet shows exemplarily how to enable and configure the decoding of Data Matrix codes:

var config = decoder.GetConfig<DataMatrix>();
config.IsEnabled = true;
config.Polarity = Polarity.DarkOnLight;
Polarity
Possible values for polarity.
Definition ConfigBase.cs:324

Note that you can enable and configure multiple code types simultaneously. The classes for all supported code types can be found within the Config namespace.

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

decoder.GetConfig<DataMatrix>().SetEnabled(true).SetPolarity(Polarity.DarkOnLight);
Template Parameters
TThe class representing the code type.
Returns
The configuration object.
Type Constraints
T :ConfigBase 

Property Documentation

◆ BasicInkjetDPMEnabled

bool BasicInkjetDPMEnabled
getset

Enable/disable reading of Basic Inkjet DPM (Direct Part Marking). This mode can read poor quality inkjet images.

Attention
If you enable this mode, the following image requirements have to be met: Width <= 1280 and Width x Height <= 1280x1024 = 1310720 pixels

◆ DetectorDensity

int DetectorDensity
getset

Sets detector density to increase or decrease the search aggressiveness for small barcodes.

Setting it to a lower value can improve robustness of decoding smaller barcodes or poorly formed 2D codes, but will also increase the decoding time. Setting to a higher value will speed up decoding with reduced robustness for decoding smaller barcodes. The default setting is 3. Value must be between 1 and 4 (inclusive).

Exceptions
ArgumentOutOfRangeExceptionIf value not between 1 and 4 (inclusive).>

Event Documentation

◆ ObjectDisposing

NativeHandleEventDelegate ObjectDisposing

Raised when this object is about to be disposed via the IDisposable.Dispose method.

This event is raised right before this object is disposed. The dispose itself cannot be canceled.