Table of Contents

Class BarcodeDetector

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

BarcodeDetector use a super resolution model. super resolution model is applied to zoom in Barcode when it is small.

public class BarcodeDetector : DisposableCvObject, IDisposable, ICvPtrHolder
Inheritance
BarcodeDetector
Implements
Inherited Members

Methods

Create(string, string)

Initialize the BarcodeDetector. It includes one models, which are packaged with caffe format. Therefore, there are prototxt and caffe models (In total, four paramenters).

public static BarcodeDetector Create(string superResolutionPrototxtPath, string superResolutionCaffeModelPath)

Parameters

superResolutionPrototxtPath string

prototxt file path for the super resolution model

superResolutionCaffeModelPath string

caffe file path for the super resolution model

Returns

BarcodeDetector

Exceptions

ArgumentException

DetectAndDecode(InputArray, out Point2f[], out string[], out string[])

Both detects and decodes barcode. To simplify the usage, there is a only API: detectAndDecode

public void DetectAndDecode(InputArray inputImage, out Point2f[] points, out string[] results, out string[] types)

Parameters

inputImage InputArray

supports grayscale or color(BGR) image.

points Point2f[]

optional output vector of vertices of the found barcode rectangle. Will be empty if not found.

results string[]

list of decoded string.

types string[]

list of decoded types.

DisposeManaged()

Releases managed resources

protected override void DisposeManaged()

SetDetectorScales(IEnumerable<float>)

Set detector box filter sizes.

Adjusts the value and the number of box filters used in the detect step. The filter sizes directly correlate with the expected line widths for a barcode.Corresponds to expected barcode distance. If the downsampling limit is increased, filter sizes need to be adjusted in an inversely proportional way.

public void SetDetectorScales(IEnumerable<float> sizes)

Parameters

sizes IEnumerable<float>

box filter sizes, relative to minimum dimension of the image (default [0.01, 0.03, 0.06, 0.08]).

SetDownsamplingThreshold(double)

Set detector downsampling threshold.

By default, the detect method resizes the input image to this limit if the smallest image size is is greater than the threshold. Increasing this value can improve detection accuracy and the number of results at the expense of performance. Correlates with detector scales.Setting this to a large value will disable downsampling.

public void SetDownsamplingThreshold(double thresh)

Parameters

thresh double

downsampling limit to apply (default 512).

SetGradientThreshold(double)

Set detector gradient magnitude threshold.

Sets the coherence threshold for detected bounding boxes. Increasing this value will generate a closer fitted bounding box width and can reduce false-positives. Values between 16 and 1024 generally work, while too high of a value will remove valid detections.

public void SetGradientThreshold(double thresh)

Parameters

thresh double

gradient magnitude threshold (default 64).