Table of contents
Swift
Objective-C

Single & Multiple Barcode Scanning

This article explains how to switch between single-barcode scanning mode and multi-barcode scanning mode.

Configure Expected Barcodes Count

  • expectedBarcodesCount = 1: Scan a single barcode.
  • expectedBarcodesCount = 0: Allows the library to return more than one result, but it does not aggressively optimize for decoding multiple barcodes.
  • expectedBarcodesCount = 999 or any other number: Makes every effort to decode up to the specified number of barcodes, when possible.
  • Objective-C
  • Swift
  1. NSError *error = nil;
    DSSimplifiedCaptureVisionSettings *captureVisionSettings = [self.cvr getSimplifiedSettings:DSPresetTemplateReadBarcodes error:&error];
    captureVisionSettings.barcodeSettings.expectedBarcodesCount = 1;
    [self.cvr updateSettings:DSPresetTemplateReadBarcodes settings:captureVisionSettings error:&error];
    
  2. guard let captureVisionSettings = try? cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue) else {
       return
    }
    captureVisionSettings.barcodeSettings?.expectedBarcodesCount = 1
    do {
       try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: captureVisionSettings)
    } catch {
    }
    

Related APIs

Improve Multi-Scan Stability

Use max overlapping feature of multi-frame cross filter to improve the stability of multi-barcode scanning.

  • Objective-C
  • Swift
  1. DSMultiFrameResultCrossFilter *filter = [[DSMultiFrameResultCrossFilter alloc] init];
    // Default value of MaxOverlapingFrames is 5. Increase the number if you want to further improve the stability.
    [filter setMaxOverlappingFrames:DSCapturedResultItemTypeBarcode frames:10];
    [filter enableLatestOverlapping:DSCapturedResultItemTypeBarcode isEnabled:YES];
    [self.cvr addResultFilter:filter];
    
  2. let filter = MultiFrameResultCrossFilter()
    // Default value of MaxOverlapingFrames is 5. Increase the number if you want to further improve the stability.
    filter.setMaxOverlappingFrames(.barcode, frames: 10)
    filter.enableLatestOverlapping(.barcode, isEnabled: true)
    cvr.addResultFilter(filter)
    

This page is compatible for: