Configure Barcode Formats
There are two ways to configure barcode formats:
- Configure formats in code.
- Configure formats together with other settings in the template.
Configure Formats in Your Code
Specify barcode formats using a combined value of EnumBarcodeFormat.
- Use bitwise OR (
|) to combine multiple formats. EnumBarcodeFormat.BF_DEFAULTincludes all common formats (BF_ONED,BF_GS1_DATABAR,BF_PDF417,BF_QR_CODE,BF_DATAMATRIX,BF_AZTEC,BF_MAXICODE,BF_MICRO_QR,BF_MICRO_PDF417, andBF_GS1_COMPOSITE).- Use
EnumBarcodeFormat.BF_ALLto enable all supported formats. -
Use group values like
EnumBarcodeFormat.BF_ONEDwhen appropriate. SimplifiedCaptureVisionSettings.barcodeSettings.barcodeFormatIds
Example:
- Objective-C
- Swift
@property (nonatomic, strong) DSCaptureVisionRouter *cvr; self.cvr = [[DSCaptureVisionRouter alloc] init]; NSError *error = nil; DSSimplifiedCaptureVisionSettings *settings = [self.cvr getSimplifiedSettings:DSPresetTemplateReadBarcodes error:&error]; DSSimplifiedBarcodeReaderSettings *barcodeSettings = settings.barcodeSettings; barcodeSettings.barcodeFormatIds = DSBarcodeFormatQRCode | DSBarcodeFormatDataMatrix; [self.cvr updateSettings:DSPresetTemplateReadBarcodes settings:settings error:&error];guard let settings = try? cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue) else { return } settings.barcodeSettings?.barcodeFormatIds = [.dataMatrix, .qrCode] do { try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings:settings) } catch { print("update runtimeSettings error:\(error.localizedDescription)") }
Configure Formats in a Template
Barcode formats are specified in BarcodeFormatIds under BarcodeReaderTaskSettingOptions. For example:
{
"CaptureVisionTemplates": [
{
"ImageROIProcessingNameArray": [ "ROI_2D" ],
"Name": "ReadCommon2D",
}
],
"TargetROIDefOptions": [
{
"Name": "ROI_2D",
"TaskSettingNameArray": [ "Task_2D" ]
}
],
"BarcodeReaderTaskSettingOptions": [
{
"Name": "Task_2D",
"BarcodeFormatIds": [ "BF_QR_CODE", "BF_DATAMATRIX", "BF_PDF417", "BF_MAXICODE" ],
"SectionArray": [
{
"Section": "ST_BARCODE_LOCALIZATION",
"ImageParameterName": "ip"
},
{
"Section": "ST_BARCODE_DECODING",
"ImageParameterName": "ip"
}
]
}
],
"ImageParameterOptions": [
{
"Name": "ip"
}
]
}
For common formats, you can download and use the preset templates below:
| Barcode Format(s) | Template |
|---|---|
| EAN13, EAN8, UPC_A, UPC_E, GS1 Databar | ReadOneDRetail.json |
| Code128, Code39, ITF, Codabar, MSI Code | ReadOneDIndustrial.json |
| QR Code | ReadQR.json |
| Data Matrix | ReadDataMatrix.json |
| PDF417 | ReadPDF417.json |
| Aztec | ReadAztec.json |
| QR Code, Data Matrix, PDF417 | ReadCommon2D.json |
| DotCode | ReadDotCode.json |