Dev Center
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.

How-to Guides - Set Custom Area for HSV Pre-detection

Since version 7.4, Dynamsoft Barcode Reader SDK is able to detect ROI (region of interest) using the HSV colour space.

It will be useful if the barcode you want to detect is near to a colour zone. For example, in supermarkets and shopping malls, the price is highlighted in red and the barcode might be near to the red zone. To boost the speed of localizing the barcode region, you can preset the colour value of the price label and the position of the barcode relative to the colour zone.

Let’s take the following image for example:

HSV Color Image

Suppose the red rectangle is the price tag and the barcode under the red rectangle (highlighted in green) is what we want to recognize.

Pre-detect Region Image

Here is the code snippet in C++:

PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings;
reader->GetRuntimeSettings(runtimeSettings);
runtimeSettings->furtherModes.regionPredetectionModes[0] = RPM_GENERAL_HSV_CONTRAST;
reader->UpdateRuntimeSettings(runtimeSettings, errorMessage, 256);
reader.SetModeArgument("regionPredetectionModes", 0, "RelativeBarcodeRegions", "[50,100,100,200,0]", errorMessage, 256); 
// [50,100,100,200,0] is the green rectangle in the image below, which is the searching area for the barcode (relative to the colour zone). 
reader.SetModeArgument("regionPredetectionModes", 0, "ForeAndBackgroundColours", "[0,-1,5]", errorMessage, 256); 
// "[0,-1,5]" - define red colour zone as ROI
reader.SetModeArgument("regionPredetectionModes", 0, "HeightRange", "[300,400]", errorMessage, 256);
reader.SetModeArgument("regionPredetectionModes", 0, "WidthRange", "[600,700]", errorMessage, 256);
reader.SetModeArgument("regionPredetectionModes", 0, "AspectRatioRange", "[25,100]", errorMessage, 256);
// invoke decode method...

For more information about region pre-detection, please see How to Use Region Predetection.

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

latest version

    • Latest version
    • Version 10.x
      • Version 10.2.0
      • Version 10.0.21
      • Version 10.0.20
      • Version 10.0.10
      • Version 10.0.0
    • Version 9.x
      • Version 9.6.42
      • Version 9.6.40
      • Version 9.6.33
      • Version 9.6.32
      • Version 9.6.31
      • Version 9.6.30
      • Version 9.6.20
      • Version 9.6.10
      • Version 9.6.0
      • Version 9.4.0
      • Version 9.2.0
      • Version 9.0.0
    • Version 8.x
      • Version 8.8.0
      • Version 8.6.0
      • Version 8.4.0
      • Version 8.2.0
      • Version 8.1.2
      • Version 8.1.0
      • Version 8.0.0
    • Version 7.x
      • Version 7.6.0
      • Version 7.5.0
    Change +