Resource Base
Table of contents

Thanks for downloading Dynamsoft Barcode Reader Package!

Your download will start shortly. If your download does not begin, click here to retry.

RegionPredetectionModes

RegionPredetectionModes is a parameter to control how to find a region of interesting. It consisits of one or more modes, each mode represents a way to find a region.

Candidate Mode List

  • RPM_AUTO
  • RPM_GENERAL
  • RPM_GENERAL_RGB_CONTRAST
  • RPM_GENERAL_GRAY_CONTRAST
  • RPM_GENERAL_HSV_CONTRAST

RPM_AUTO

Lets the library choose a mode automatically.

RPM_GENERAL

Takes the whole image as a region. This mode has the following arguments for further customizing.

RPM_GENERAL_RGB_CONTRAST

Detects region using the general algorithm based on RGB colour contrast. This mode has the following arguments for further customizing.

RPM_GENERAL_GRAY_CONTRAST

Detects region using the general algorithm based on gray contrast. This mode has the following arguments for further customizing.

RPM_GENERAL_HSV_CONTRAST

Detects region using the general algorithm based on HSV colour contrast. This mode has the following arguments for further customizing.

Setting Methods

As PublicRuntimeSettings Member

RegionPredetectionModes can be set dynamically during runtime as a member of FurtherModes, which is a member of PublicRuntimeSettings struct, it is an array with 8 RegionPredetectionMode Enumeration items.

Code Snippet in C++

//...other codes
PublicRuntimeSettings* pSettings = new PublicRuntimeSettings;
int errorCode = reader->GetRuntimeSettings(pSettings);
pSettings->regionPredetectionModes[0] = RPM_GENERAL_RGB_CONTRAST;
reader->UpdateRuntimeSettings(pSettings);
reader->SetModeArgument("RegionPredetectionModes", 0, "Sensitivity", "5");
delete pSettings;
//...other codes

Remarks
GetModeArgument and SetModeArgument need to be called for getting and setting Arguments.

See Also

As JSON Parameter

RegionPredetectionModes as a JSON parameter is a JSON Object array. Each JSON object is defined as below.

Key Name Key Value Description
Mode Any one in Candidate Mode List as string (Required) Specifies a mode to find a region.
AspectRatioRange A string from value range of AspectRatioRange (Optional) Sets the Argument AspectRatioRange.
FindAccurateBoundary A number from value range of FindAccurateBoundary (Optional) Sets the Argument FindAccurateBoundary.
ForeAndBackgroundColours A string from value range of ForeAndBackgroundColours (Optional) Sets the Argument ForeAndBackgroundColours.
HeightRange A string from value range of HeightRange (Optional) Sets the Argument HeightRange.
MinImageDimension A number from value range of MinImageDimension (Optional) Sets the Argument MinImageDimension.
RelativeBarcodeRegions A string from value range of RelativeBarcodeRegions (Optional) Sets the Argument RelativeBarcodeRegions.
Sensitivity A number from value range of Sensitivity (Optional) Sets the Argument Sensitivity.
SpatialIndexBlockSize A number from value range of SpatialIndexBlockSize (Optional) Sets the Argument SpatialIndexBlockSize.
WidthRange A string from value range of WidthRange (Optional) Sets the Argument WidthRange.
LibraryFileName A string from value range of LibraryFileName (Optional) Sets the Argument LibraryFileName.
LibraryParameters A string from value range of LibraryFileName (Optional) Sets the Argument LibraryFileName.

JSON Parameter Example

{
    "RegionPredetectionModes": [
        {
            "Mode": "RPM_GENERAL_RGB_CONTRAST", 
            "Sensitivity": 5
        },
        {
            "Mode": "RPM_GENERAL_HSV_CONTRAST", 
            "WidthRange": "[100, 200]"
        }
    ]
}

Impacts on Performance

Speed

The SDK will loop the setting modes one by one until find as many barcodes as ExpectedBarcodesCount specified or timeout. The more modes you set, the more time the process may take. Setting an appropriate mode first in order or setting only necessary modes may speed up the process. Enabling region predetection on images with obvious colour features may speed up the process.

Read Rate

Setting more modes along with different arguments may improve the Read Rate.

Accuracy

RegionPredetectionModes has no influence on the Accuracy.

Candidate Argument List

AspectRatioRange

Specifies a set (or multiple sets) of aspect ratio range for filtering the predetected region.

Value Type Value Range Default Value Valid For
string A string value representing aspect ratio range sets. ”” RPM_GENERAL_HSV_CONTRAST

Remarks

  • A set of aspect ratio range is defined as [MinAspectRatio, MaxAspectRatio].
  • Using a “”;”” to separate multiple sets.
  • Value range of MinAspectRatio, MaxAspectRatio: [1,10000]
  • Aspect ratio equals to height/width*100, while the height and width is from the bounding rectangle of the predetected region.

FindAccurateBoundary

Sets whether to enable finding accurate boundary.

Value Type Value Range Default Value
int [0, 1] 0

Remarks

  • 0: disable.
  • 1: enable.

ForeAndBackgroundColours

Specifies a set (or multiple sets) of the foreground and background colours used for region predetection algorithm.

Value Type Value Range Default Value
string A string value representing one or more colour sets. ””

Remarks

  • This argument is mandatory for RPM_GENERAL_HSV_CONTRAST mode. If there is no manual setting, no region can be detected.
  • A set of the foreground and background colours is defined as [ForegroundColour, BackgroundColour, Tolerance].
  • Using a “”;”” to separate multiple sets.
  • ForegroundColourand BackgroundColour are the Hue values in the HSV colour space for defining the foreground and background colours of the regions you want to predetect. The value -1 means black, gray, white.
  • Tolerance is the allowable deviation of the Hue value defined by ForegroundColour.
  • Value range of ForegroundColour, BackgroundColour: [-1,360]
  • Value range of Tolerance: [0, 360]

HeightRange

Specifies a set (or multiple sets) of height range for filtering the predetected region.

Value Type Value Range Default Value Valid For
string A string value representing height range sets. ”” RPM_GENERAL_HSV_CONTRAST

Remarks

  • A set of height is defined as [MinHeight, MaxHeight].
  • Using a “”;”” to separate multiple sets.
  • Value range of MinHeight, MaxHeight: [1, 0x7fffffff]
  • The height value is the height of the bounding rectangle of the predetected region.

MinImageDimension

Sets the minimum image dimension (in pixels) to enable region pre-detection.

Value Type Value Range Default Value Valid For
int [16384, 0x7fffffff] 262144 RPM_GENERAL_HSV_CONTRAST
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST

Remarks
The library will enable the region pre-detection feature only when the image dimension is larger than the given value.

RelativeBarcodeRegions

Sets the barcode regions relative to the predetected region.

Value Type Value Range Default Value Valid For
string A string value representing one or more regions. ”” RPM_GENERAL_HSV_CONTRAST

Remarks

  • Each region need to be defined as [Left, Top, Right, Bottom, Index]. If you want to define multiple regions, you can use a “”;”” to separate them. If there is no region defined, the library will consider the predetected regions as barcode regions.
  • Left, Top, Right, Bottom are four percentage values relative to top-left corner of the predetected region.
  • Index means the index of a specific colour set in ForeAndBackgroundColours which the current region is applied to. If the value of index is set to -1, the current region will be applied to all colour sets in ForeAndBackgroundColours.
  • Value range of Left, Top, Right, Bottom: [-10000,10000]
  • Value range of Index: [-1, 0x7fffffff]

Sensitivity

Sets the sensitivity used for region predetection algorithm.

Value Type Value Range Default Value Valid For
int [1, 9] 1 RPM_GENERAL_HSV_CONTRAST
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST

Remarks
A larger value means the library will take more effort to detect regions.

SpatialIndexBlockSize

Sets the spatial index block size used for region predetection algorithm.

Value Type Value Range Default Value Valid For
int [1, 32] 5 RPM_GENERAL_HSV_CONTRAST
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST

Remarks
The block size used for region predetection would be 2 to the power of N. The allowed values of SpatialIndexBlockSize is the power number (N=1,2,3…).

WidthRange

Specifies a set (or multiple sets) of width range for filtering the predetected region.

Value Type Value Range Default Value Valid For
string A string value representing width range sets. ”” RPM_GENERAL_HSV_CONTRAST

Remarks

  • A set of width is defined as [MinWidth, MaxWidth].
  • Using a “”;”” to separate multiple sets.
  • Value range of MinWidth, MaxWidth: [1, 0x7fffffff]
  • The width value is the width of the bounding rectangle of the predetected region.

LibraryFileName

Sets the file name of the library to load dynamically.

Value Type Value Range Default Value Valid For
string A string value representing file name. ”” All modes

Remarks
The library must be in the same place with Dynamsoft Barcode Reader Library.

LibraryParameters

Sets the parameters passed to the library to load dynamically.

Value Type Value Range Default Value Valid For
string A string value representing parameters. ”” All modes

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 8.8.0
  • Version 8.6.3
  • Version 8.6.1
  • Version 8.6.0
  • Version 8.4.0
  • Version 8.2.5
  • Version 8.2.3
  • Version 8.2.1
  • Version 8.2.0
  • Version 8.1.3
  • Version 8.1.2
  • Version 8.1.0
  • Version 8.0.0
  • Version 7.6.0
  • Version 7.5.0
Change +
© 2003–2021 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support