Label Definitions
A Label Definition is a configuration that defines the label, and its relevant fields, that Smart Label Capture should recognize and extract during scans.
Smart Label Capture provides a Label Definition API, enabling you to configure and extract structured data from predefined and custom labels. This feature provides a flexible way to recognize and decode fields within a specific label layout such as price tags, VIN labels, or packaging stickers without needing to write custom code for each label type.
There are two approaches to using label definitions:
Pre-built Labels
Smart Label Capture includes ready-made label definitions for common use cases. These pre-built options let you recognize and extract information from standard label types without creating custom configurations:
- Price Label: This factory method is designed for price checking scenarios where both barcode and price text need to be captured from product labels. Returns
SKUandpriceTextfields. - VIN Label: A predefined label definition for scanning Vehicle Identification Numbers (VIN). Returns
textand/orbarcodefields.
Example: Price label
Create a label definition for price labels, such as those found in retail environments:

// Create a barcode field for the SKU.
final skuField = CustomBarcodeBuilder()
.setSymbologies([Symbology.ean13Upca, Symbology.code128])
.build('SKU');
// Create a text field for the price.
final priceField = TotalPriceTextBuilder()
.build('priceText');
// Create a label definition for the price label.
final priceLabel = LabelDefinitionBuilder()
.addCustomBarcode(skuField)
.addTotalPriceText(priceField)
.build('price-label');
// Create the label capture settings using the builder pattern.
final settings = LabelCaptureSettingsBuilder()
.addLabel(priceLabel)
.build();
Custom Labels
If Smart Label Capture’s pre-built options don’t fit your needs, define a custom label instead. Custom labels can combine your own fields with any of the available pre-built ones.
The following characters are recognized: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ()-./:,$¶".
Custom Fields
There are two types of custom fields you can define:
The following builder methods are available to configure custom fields:
| Method | Required | Description |
|---|---|---|
setSymbology() / setSymbologies() | Yes (barcode fields) | The barcode symbologies to match for barcode fields. This is important for ensuring that the field only captures data from specific barcode types, enhancing accuracy and relevance. |
isOptional() | No | Whether the field is optional or mandatory. This is helpful when certain fields may not be present on every scan. |
setHiddenProperty() | No | Set hidden properties for advanced configuration. |
Example: Fish Shipping Box
This example shows how to create a custom label definition for a fish shipping box, which includes fields for barcode and batch number.

// Create a barcode field with Code 128 symbology.
final barcodeField = CustomBarcodeBuilder()
.setSymbology(Symbology.code128)
.build('barcode-field');
// Create a custom text field for the batch number.
final batchNumberField = CustomTextBuilder()
.isOptional(true)
.build('batch-number-field');
// Create a label definition using the builder pattern.
final shippingLabel = LabelDefinitionBuilder()
.addCustomBarcode(barcodeField)
.addCustomText(batchNumberField)
.build('shipping-label');
// Create the label capture settings.
final settings = LabelCaptureSettingsBuilder()
.addLabel(shippingLabel)
.build();
Pre-built Fields
You can also configure your label by using pre-built fields. These are some common fields provided for faster integration, with all patterns, dataTypePattern, and symbologies already predefined.
Customization of pre-built fields is done via the patterns, dataTypePatterns, and isOptional methods, which allow you to specify the expected format of the field data.
All pre-built fields come with predefined patterns that are suitable for most use cases. You can use setHiddenProperty() for advanced customization if needed.
Barcode Fields
SerialNumberBarcode: A barcode field for capturing serial numbers, typically used in electronics and appliances.PartNumberBarcode: A barcode field for capturing part numbers, commonly used in manufacturing and inventory management.ImeiOneBarcode: A barcode field for capturing the first International Mobile Equipment Identity (IMEI) number, used in mobile devices.ImeiTwoBarcode: A barcode field for capturing the second International Mobile Equipment Identity (IMEI) number, used in mobile devices.
Price and Weight Fields
UnitPriceText: A text field for capturing the unit price of an item, often used in retail and grocery labels.TotalPriceText: A text field for capturing the total price of an item, typically used in retail and grocery labels.WeightText: A text field for capturing the weight of an item, commonly used in shipping and logistics.
Date and Custom Text Fields
PackingDateText: A text field for capturing the packing date of an item, often used in food and beverage labels.ExpiryDateText: A text field for capturing the expiry date of an item, commonly used in pharmaceuticals and food products.
Example: Hard disk drive label
This example demonstrates how to configure a label definition for a hard disk drive (HDD) label, which typically includes common fields like serial number and part number.

// Create a serial number barcode field.
// Pre-built fields like SerialNumberBarcode have predefined patterns.
final serialNumberField = SerialNumberBarcodeBuilder()
.setSymbology(Symbology.code128)
.build('serial-number');
// Create a part number barcode field.
final partNumberField = PartNumberBarcodeBuilder()
.setSymbology(Symbology.code128)
.build('part-number');
// Create a label definition using the builder pattern.
final hddLabel = LabelDefinitionBuilder()
.addSerialNumberBarcode(serialNumberField)
.addPartNumberBarcode(partNumberField)
.build('hdd-label');
// Create the label capture settings.
final settings = LabelCaptureSettingsBuilder()
.addLabel(hddLabel)
.build();