Table of contents
Swift
Objective-C

Understanding Barcode Results

DecodedBarcodesResult is the barcode-type result returned by the Dynamsoft Barcode Reader SDK. It represents all barcode-related information captured from a single image or video frame.

It contains:

  • All decoded barcodes.
  • Metadata about the original image.
  • Error information when a failure occurs.
  • A rotation transformation matrix if the original image includes rotation info.
  • Objective-C
  • Swift
  1. - (void)onDecodedBarcodesReceived:(DSDecodedBarcodesResult *)result
    {
       if (result.items.count != 0)
       {
          for (DSBarcodeResultItem *item in result.items)
          {
             NSString *barcodeText = barcodeResultItem.text;
             NSString *barcodeFormatString = barcodeResultItem.formatString;
          }
       }
    }
    
  2. func onDecodedBarcodesReceived(_ result: DecodedBarcodesResult) {
       if let items = result.items, !items.isEmpty {
          for item in items {
             let barcodeText = barcodeResultItem.text
             let barcodeFormatString = barcodeResultItem.formatString
          }
       }
    }
    

How to Use

Check Error Messages

Error messages are typically caused by:

  • The barcode reading task is not working properly.
  • The operation timeout.
  • Objective-C
  • Swift
  1. - (void)onDecodedBarcodesReceived:(DSDecodedBarcodesResult *)result
    {
       if (result.errorCode != 0)
       {
          // Handle the error.
       }
    }
    
  2. func onDecodedBarcodesReceived(_ result: DecodedBarcodesResult) {
       if result.errorCode != 0 {
          // Handle the error.
       }
    }
    

You might still receive barcode results even when the error message is not empty.

Access decoded barcodes

Each decoded barcode is a BarcodeResultItem from result.items. The following is an example:

barcode-result-item

BarcodeResultItem  
format 67108864
formatString QR_CODE
text www.dynamsoft.com
bytes [119],[119],[119],[46],[100],[121],……
location Point(196, 1101), Point(518, 1000),……
confidence 86
angle 345
moduleSize 10
isDPM FALSE
isMirrored FALSE
details rows = 2
columns = 2
errorCorrectionLevel = L
version = 2
model = 2
mode = 7
page = -1
totalPage = -1
parityData = 0
dataMaskPattern = 2
codewords = ……

Common fields to use

  • text: The decoded string. This is the most common field used for downstream processing.
  • formatString: The barcode symbology (for example, QR_CODE, EAN_13).
  • bytes: Raw payload bytes. By default, barcode text is interpreted using ISO-8859-1. Use this when the payload contains binary data or requires custom decoding.
  • location: Corner points of the barcode in the image, useful for drawing overlays.
  • confidence: A confidence score. Higher values indicate more reliable decoding.
  • details: Symbology-specific details (varies by barcode type).

Access the Original Image

The original image is not returned by default. In onDecodedBarcodesReceived, you receive the original image HashId. Use it to fetch the image when needed.

Code Snippet

  • Objective-C
  • Swift
  1. -(void)onDecodedBarcodesReceived:(DSDecodedBarcodesResult *)result
    {
       DSImageData *originalImage = [[_cvr getIntermediateResultManager] getOriginalImage:result.originalImageHashId];
    }
    
  2. func onDecodedBarcodesReceived(_ result: DecodedBarcodesResult)
    {
       let originalImage = cvr.getIntermediateResultManager().getOriginalImage(result.originalImageHashId)
    }
    

Use originalImage within the lifecycle of each onDecodedBarcodesReceived callback. Otherwise, it may be released or replaced by a newer image.

Related APIs

Explore Result Details

This page provides a high-level overview of barcode scan results. For detailed usage and advanced scenarios, see:

This page is compatible for: