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 Control the Terminate Phase for DBR

Normally, DBR will terminate after decoding is complete. Considering requirement diversity, we provide the TerminatePhaseparameter for the user to specify the specific moment to terminate the DBR instance. The Timeoutparameter controls the time consumed during the decoding phase. Should the decoding phase exceed the value of Timeout, DBR will terminate immediately.

Timeout

This parameter specifies the timeout for the DBR algorithm in milliseconds, values ranging from[0,0x7fffffff]. Default value is 10000. When DBR times out, it will terminate and return an error code related to the timeout. When dealing with multiple images, the user needs to consider a comprehensive timeout value to balance the trade-off between speed and accuracy for each image. The following code snippet illustrates how to set the Timeout:

char sError[512];   
TextResultArray* paryResult = NULL;   
PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings();   
CBarcodeReader* reader = new CBarcodeReader();   
reader->InitLicense("input your license");  
reader->GetRuntimeSettings(runtimeSettings); //Configure runtimesettings   
runtimeSettings->timeout = 1000; //set timeout
reader->UpdateRuntimeSettings(runtimeSettings, sError, 512); //Update runtimesettings     
reader->DecodeFile("input your file path", ""); //Decoding  
reader->GetAllTextResults(&paryResult); //Get results     
dynamsoft::dbr::CBarcodeReader::FreeTextResults(&paryResult);   
delete runtimeSettings;   
delete reader; 

TerminatePhase

This parameter can specify a certain stage to terminate the DBR algorithm. The main stages for the DBR algorithm are:

  • Region Pre-detection
  • Image Preprocessing
  • Image binarization
  • Barcode localization
  • Barcode type identification
  • Barcode decoding/recognition

DBR algorithm will terminate after all of the above stages are complete. Customized termination options could be achieved by adjusting TerminatePhaseparameter to terminate the algorithm in advance. After termination, the user could obtain effective information from IntermediateResult. Before demonstrating how to use the parameter, here is a quick overview of the TerminatePhase enumerations:

Enumeration name Note
TP_REGION_PREDETECTED Terminate after Region Pre-detected
TP_IMAGE_PREPROCESSED Terminate after Image Preprocessed
TP_IMAGE_BINARIZED Terminate after Image binarized
TP_BARCODE_LOCALIZED Terminate after Barcode localized
TP_BARCODE_TYPE_DETERMINED Terminate after Barcode type identified
TP_BARCODE_RECOGENIZED Terminate after Barcode recognized

Following code snippet illustrate how to set the TerminatePhase

char sError[512];   
TextResultArray* paryResult = NULL;   
PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings();   
CBarcodeReader* reader = new CBarcodeReader();   
reader->InitLicense("input your license");  
reader->GetRuntimeSettings(runtimeSettings); //Configure runtimesettings  
runtimeSettings->terminatePhase = TP_BARCODE_RECOGNIZED; //Specify terminate phase
reader->UpdateRuntimeSettings(runtimeSettings, sError, 512); //Update runtimesettings  
reader->DecodeFile("input your file path", ""); //Decoding
reader->GetAllTextResults(&paryResult); //Get results  
dynamsoft::dbr::CBarcodeReader::FreeTextResults(&paryResult);
delete runtimeSettings;
delete reader;
 

Template

You could also set the TerminatePhaseparameter via the JSON settings template. In the below JSON template, we set TerminatePhase to TP_BARCODE_LOCALIZED, so that the algorithm terminates once the barcode(s) are localized. In this case, the value of Timeoutis 1000, which means if the time consumed exceeds 1000 milliseconds, the DBR algorithm will terminate.

{
    "ImageParameter": {
        "BarcodeFormatIds": ["BF_ALL"],
        "TerminatePhase":"TP_BARCODE_LOCALIZED",
        "Timeout": 1000
    },
    "Version": "3.0"
}

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.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 +