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.

Specify Barcode Formats and Count

Set Barcode Formats

Specifying the barcode format is always the first step when it comes to the configuration of Dynamsoft Barcode Reader(DBR). Be sure to confirm that the target barcode formats are indeed supported by DBR by checking our list of supported barcode types. Excluding undesired barcode types will improve the processing efficiency.

You can configure the parameter in two different ways, depending on your requirements. You can do it through SimplifiedCaptureVisionSettings, or if it suits your needs better, you can opt for JSON Template. Below are examples illustrating both of these configuration methods:

  • Configure barcode format via SimplifiedCaptureVisionSettings.
  • C++
  • Android
  • Objective-C
  • Swift
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `CCaptureVisionRouter` instance.
CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
SimplifiedCaptureVisionSettings settings;
cvr->GetSimplifiedSettings(CPresetTemplate::PT_READ_BARCODES, &settings);
// Specify the barcode formats by enumeration values.
// Use "|" to enable multiple barcode formats at one time.
settings.barcodeSettings.barcodeFormatIds = BF_QR_CODE | BF_ONED;
// Update the settings.
cvr->UpdateSettings(CPresetTemplate::PT_READ_BARCODES, &settings, szErrorMsg, 256);
try {
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   SimplifiedCaptureVisionSettings captureVisionSettings = cvr.getSimplifiedSettings(EnumPresetTemplate.PT_READ_BARCODES);
   captureVisionSettings.barcodeSettings.barcodeFormatIds = EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_ONED;
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   cvr.updateSettings(EnumPresetTemplate.PT_READ_BARCODES, captureVisionSettings);
} catch (CaptureVisionRouterException e) {
   e.printStackTrace();
}
NSError *error;
// Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
// Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
DSSimplifiedCaptureVisionSettings *captureVisionSettings = [self.cvr getSimplifiedSettings:DSPresetTemplateReadBarcodes error:&error];
captureVisionSettings.barcodeSettings.barcodeFormatIds = DSBarcodeFormatQRCode | DSBarcodeFormatOneD;
// Update the settings. Remember to specify the same template name you used when getting the settings.
[self.cvr updateSettings:DSPresetTemplateReadBarcodes settings:captureVisionSettings error:&error];
do{
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   let captureVisionSettings = try cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue)
   captureVisionSettings.barcodeSettings?.barcodeFormatIds = [.qrCode,.oneD]
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: captureVisionSettings)
}catch{
   // Add code to do when error occurs.
}
  • Configure barcode format via JSON parameter template file
    • update parameter BarcodeFormatIds in your JSON template
      {
          "CaptureVisionTemplates": [
              {
                  "Name" : "CV_0",
                  "ImageROIProcessingNameArray": ["TA_0" ]
              }       
          ],
          "TargetROIDefOptions" : [
              {
                  "Name" : "TA_0",
                  "TaskSettingNameArray": [ "BR_0" ]
              }
          ],
          "BarcodeReaderTaskSettingOptions": [
              {
                  "Name" : "BR_0",
                  "BarcodeFormatIds" : ["BF_ONED", "BF_QR_CODE"]
              }
          ]
      }
      
    • apply settings by calling method InitSettingsFromFile

      • C++
      • Android
      • Objective-C
      • Swift
      char szErrorMsg[256] = {0};
      CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
      cvr->InitSettingsFromFile("PATH-TO-YOUR-SETTING-FILE", szErrorMsg, 256);
      // more process here
      
      try {
         // `cvr` is an instance of `CaptureVisionRouter`.
         cvr.initSettingsFromFile("PATH-TO-YOUR-SETTING-FILE");
      } catch (CaptureVisionRouterException e) {
         e.printStackTrace();
      }
      
      NSError *error;
      // `cvr` is an instance of `DSCaptureVisionRouter`.
      [self.cvr initSettingsFromFile:@"PATH-TO-YOUR-SETTING-FILE" error:&error];
      
      do{
         //`cvr` is an instance of `CaptureVisionRouter`.
         try cvr.initSettingsFromFile("PATH-TO-YOUR-SETTING-FILE")
      }catch{
         // Add code to do when error occurs.
      }
      

Set Barcode Count

The expectedBarcodeCount parameter controls the number of expected results of the recognized barcodes from a single image. The process will be stopped as soon as the count of successfully decoded barcodes reaches the expected amount.

There are some suggestions on how to set the expectedBarcodeCount:

  • When your project is designed for decoding a single barcode per image or frame, the recommended expectedBarcodeCount is 1. This will sharply improve the processing speed.
  • When there are n barcodes in a single image or frame (n is a fixed number) and you’d like the barcode reader to decode all of them, the recommended expectedBarcodeCount is n.
  • When the number of barcodes is unknown and you want to output as many barcode results as possible, you can set the expectedBarcodeCount to the maximum possible value of expectedBarcodeCount.
  • When the number of barcodes is unknown and you want to output at least one barcode result as soon as possible, you can set the expectedBarcodeCount to 0. The barcode reader will try to decode at least one barcode from the image.

You can configure the parameter in two different ways, depending on your requirements. You can do it through SimplifiedBarcodeReaderSettings, or if it suits your needs better, you can opt for JSON Template. Below are examples illustrating both of these configuration methods:

  • Configure expected barcode count via SimplifiedCaptureVisionSettings.
  • C++
  • Android
  • Objective-C
  • Swift
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `CCaptureVisionRouter` instance.
CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
SimplifiedCaptureVisionSettings settings;
cvr->GetSimplifiedSettings(CPresetTemplate::PT_READ_BARCODES, &settings);
// Specify the expected barcode count.
settings.barcodeSettings.expectedBarcodesCount = 1;
// Update the settings.
cvr->UpdateSettings(CPresetTemplate::PT_READ_BARCODES, &settings, szErrorMsg, 256);
try {
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   SimplifiedCaptureVisionSettings captureVisionSettings = cvr.getSimplifiedSettings(EnumPresetTemplate.PT_READ_BARCODES);
   captureVisionSettings.barcodeSettings.expectedBarcodesCount = 1;
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   cvr.updateSettings(EnumPresetTemplate.PT_READ_BARCODES, captureVisionSettings);
} catch (CaptureVisionRouterException e) {
   e.printStackTrace();
}
NSError *error;
// Obtain current runtime settings. `cvr` is an instance of `DSCaptureVisionRouter`.
// Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
DSSimplifiedCaptureVisionSettings *captureVisionSettings = [self.cvr getSimplifiedSettings:DSPresetTemplateReadBarcodes error:&error];
captureVisionSettings.barcodeSettings.expectedBarcodesCount = 1;
// Update the settings. Remember to specify the same template name you used when getting the settings.
[self.cvr updateSettings:DSPresetTemplateReadBarcodes settings:captureVisionSettings error:&error];
do{
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   let captureVisionSettings = try cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue)
   captureVisionSettings.barcodeSettings?.expectedBarcodesCount = 1
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: captureVisionSettings)
}catch{
   // Add code to do when error occurs.
}
  • Configure barcode format via JSON parameter template file
    • update parameter ExpectedBarcodesCount in your JSON template
      {
          "CaptureVisionTemplates": [
              {
                  "Name" : "CV_0",
                  "ImageROIProcessingNameArray": ["TA_0" ]
              }       
          ],
          "TargetROIDefOptions" : [
              {
                  "Name" : "TA_0",
                  "TaskSettingNameArray": [ "BR_0" ]
              }
          ],
          "BarcodeReaderTaskSettingOptions": [
              {
                  "Name" : "BR_0",
                  "ExpectedBarcodesCount" : 1
              }
          ]
      }
      
    • apply settings by calling method InitSettingsFromFile

      • C++
      • Android
      • Objective-C
      • Swift
      char szErrorMsg[256] = {0};
      CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
      cvr->InitSettingsFromFile("PATH-TO-YOUR-SETTING-FILE", szErrorMsg, 256);
      // more process here
      
      try {
         // `cvr` is an instance of `CaptureVisionRouter`.
         cvr.initSettingsFromFile("PATH-TO-YOUR-SETTING-FILE");
      } catch (CaptureVisionRouterException e) {
         e.printStackTrace();
      }
      
      NSError *error;
      // `cvr` is an instance of `DSCaptureVisionRouter`.
      [self.cvr initSettingsFromFile:@"PATH-TO-YOUR-SETTING-FILE" error:&error];
      
      do{
         //`cvr` is an instance of `CaptureVisionRouter`.
         try cvr.initSettingsFromFile("PATH-TO-YOUR-SETTING-FILE")
      }catch{
         // Add code to do when error occurs.
      }
      

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

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 +