Table of contents

Need better scanning performance?

Get a FREE customized reading template.

RegionPredetectionModes

Parameter RegionPredetectionModes controls how to find a region of interest (ROI) within the image or frame.

{
    "RegionPredetectionModes": [
        {
            "Mode": "RPM_GENERAL_GRAY_CONTRAST", 
            "Sensitivity": 5
        },
        {
            "Mode": "RPM_GENERAL_RGB_CONTRAST", 
            "Sensitivity": 5
        },
        {
            "Mode": "RPM_GENERAL_HSV_CONTRAST", 
            "ForeAndBackgroundColours":"[20,170,10]",
            "WidthRange": "[100, 200]"
        },
        {
            "Mode": "RPM_NEURAL_NETWORK",
            "DetectionModelName": ""
        }        
    ]
}

Parameter Summary

Mode Arguments

Parameter RegionPredetectionModes consist of a group of region predetection mode objects. Each region predetection mode object includes a candidate mode and a series of mode arguments. The mode arguments of the region predetection mode object is shown as follow:

Mode Argument Name Mode Argument Summary
Mode
(Required)
Description
Any one in Candidate Mode List as string
Type
String
Candidate Mode List
RPM_SKIP
RPM_AUTO
RPM_GENERAL
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST
RPM_GENERAL_HSV_CONTRAST
RPM_GRAY_CONSISTENCY
AspectRatioRange
(Optional)
Description
Specifies one or multiple sets of aspect ratio ranges as a string for filtering the predetected region.

Aspect Ratio = BoundingRectHeight/BoundingRectWidth * 100
Type
String
Substruct
Define one range:
"[MinAspectRatio, MaxAspectRatio]"
Define multiple ranges:
"[MinAspectRatio, MaxAspectRatio];[MinAspectRatio, MaxAspectRatio];..."
Range
MinAspectRatio: [0,10000]
MaxAspectRatio: [0,10000]
Valid For
RPM_GENERAL_HSV_CONTRAST
FindAccurateBoundary
(Optional)
Description
Sets whether to enable finding accurate boundary:
0: disable.
1: enable.
Type
int
Range
[0,1]
Valid For
RPM_GENERAL_HSV_CONTRAST
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST
ForeAndBackgroundColours
(Required by RPM_GENERAL_HSV_CONTRAST )
Description
Specifies a set (or multiple sets) of the foreground and background colours used for region predetection algorithm based on HSV colour space:
Type
String
Substruct
Define one range:
"[ForegroundColour,BackgroundColour,Tolerance]"
Define multiple ranges:
"[ForegroundColour,BackgroundColour,Tolerance];[ForegroundColour,BackgroundColour,Tolerance];..."
Range
ForegroundColour: [-1,360]
BackgroundColour: [-1,360]
Tolerance: [0, 360]
Valid For
RPM_GENERAL_HSV_CONTRAST
HeightRange
(Optional)
Description
Specifies a set (or multiple sets) of height range for filtering the predetected region. The height is measured by the height of the bounding rect of the predetected region.
Type
String
Substruct
Define one range:
"[MinHeight, MaxHeight]"
Define multiple ranges:
"[MinHeight, MaxHeight];[MinHeight, MaxHeight];..."
Range
MinHeight: [1, 0x7fffffff]
MaxHeight: [1, 0x7fffffff]
Valid For
RPM_GENERAL_HSV_CONTRAST
WidthRange
(Optional)
Description
Specifies a set (or multiple sets) of width range for filtering the predetected region. The width is measured by the width of the bounding rect of the predetected region.
Type
String
Substruct
Define one range:
"[MinWidth, MaxWidth]"
Define multiple ranges:
"[MinWidth, MaxWidth];[MinWidth, MaxWidth];..."
Range
A string value representing height range sets.
Valid For
RPM_GENERAL_HSV_CONTRAST
MinImageDimension
(Optional)
Description
Sets the minimum image dimension (in pixels) to enable region pre-detection. The library will enable the region pre-detection feature only when the image dimension is larger than the given value.
Type
int
Range
[16384, 0x7fffffff]
Valid For
RPM_GENERAL_HSV_CONTRAST
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST
RelativeRegions
(Optional)
Description
Sets the barcode regions relative to the pre-detected region.
Type
String
Substruct
Define one region:
"[Left,Top,Right,Bottom,Index]"
Define multiple region:
"[Left,Top,Right,Bottom,Index];[Left,Top,Right,Bottom,Index];..."
Range
Left, Top, Right, Bottom: [-10000,10000]
Index: [-1,0x7fffffff]
Valid For
RPM_GENERAL_HSV_CONTRAST
Remarks
Parameters Left, Top, Right, Bottom are measured in percentage.
Parameter Index points to a specific colour that set in ForeAndBackgroundColours. Set it to -1 to apply the current RelativeRegion to all ForeAndBackgroundColours.
Sensitivity
(Optional)
Description
Sets the sensitivity used for region predetection algorithm, a larger value means the library will take more effort to detect regions.
Type
int
Range
[1,9]
Valid For
RPM_GENERAL_HSV_CONTRAST
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST
SpatialIndexBlockSize
(Optional)
Description
Sets the spatial index block size used for region predetection algorithm. 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…).
Type
int
Range
[1, 32]
Default Value
5
Valid For
RPM_GENERAL_HSV_CONTRAST
RPM_GENERAL_RGB_CONTRAST
RPM_GENERAL_GRAY_CONTRAST
GrayRange
(Optional)
Description
Sets the target grayscale value range, formatted as [MinGrayValue, MaxGrayValue], for candidate regions.
Type
Int Array
Range
MinGrayValue: [0,255]
MaxGrayValue: [0,255]
Default Value
[0,255]
Valid For
RPM_GRAY_CONSISTENCY.
MatchRatio
(Optional)
Description
Sets the minimum percentage of pixels within a spatial block that must fall into the `GrayRange` for the block to be considered consistent.
Type
Int
Range
[0, 100]
Default Value
50
Valid For
RPM_GRAY_CONSISTENCY

Default Setting

The default settings of RegionPredetectionModes is:

{
    "RegionPredetectionModes" : 
    [
        {
            "AspectRatioRange" : "[]",
            "FindAccurateBoundary" : 0,
            "ForeAndBackgroundColours" : "[]",
            "HeightRange" : "[]",
            "ImageParameterName" : "",
            "MeasuredByPercentage" : 1,
            "MinImageDimension" : 262144,
            "Mode" : "RPM_GENERAL",
            "RelativeRegions" : "[]",
            "Sensitivity" : 1,
            "SpatialIndexBlockSize" : 5,
            "WidthRange" : "[]"
        }
    ],
}

Candidate Modes Introduction

RPM_SKIP

Skip region pre-detection process.

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.

Available Mode Arguments:

  • MinImageDimension
  • Sensitivity
  • SpatialIndexBlockSize

RPM_GENERAL_GRAY_CONTRAST

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

Available Mode Arguments:

  • MinImageDimension
  • Sensitivity
  • SpatialIndexBlockSize

RPM_GENERAL_HSV_CONTRAST

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

Available Mode Arguments:

  • AspectRatioRange
  • FindAccurateBoundary
  • ForeAndBackgroundColours
  • HeightRange
  • WidthRange
  • RelativeBarcodeRegions
  • MinImageDimension
  • Sensitivity
  • SpatialIndexBlockSize

RPM_GRAY_CONSISTENCY

Detects regions in a grayscale image where pixel values fall within a specified gray range and demonstrate local consistency. This is useful for locating areas with uniform brightness, such as document backgrounds or label zones.

Available Mode Arguments:

  • GrayRange
  • MatchRatio

Remarks

  • Introduced in Dynamsoft Barcode Reader SDK version 11.2.1000 and Dynamsoft Capture Vision version 3.2.1000.

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: