Captured Field

Defined in framework ScanditLabelCapture

LabelField
open class LabelField : NSObject

Added in version 6.0.0

Represents a captured field within a label. Each field corresponds to a specific data element defined in the LabelDefinition and contains the actual captured data along with metadata about its state, location, and type.

Fields can be either barcode fields (containing Barcode data) or text fields (containing string data), and may include additional semantic information such as parsed dates.

Processing captured fields:

for field in capturedFields {
    let value = field.barcode?.data ?? field.text ?? formatDate(field.asDate())
    print("\(field.name): \(value)")
}
name
open var name: String { get }

Added in version 6.0.0

The unique identifier for this captured field within the label. This name corresponds to the field name specified in the LabelDefinition when configuring the label structure. For example, field names might be “barcode”, “price”, “expiry_date”, etc.

type
open var type: LabelFieldType { get }

Added in version 6.0.0

Identifies the type of the captured field type. This either returns LabelFieldType.barcode, or LabelFieldType.text. Depending on the type, further information such as captured data is available through the following properties:

valueType
open var valueType: LabelFieldValueType { get }

Added in version 7.4.0

Identifies the semantic value type of the captured field, providing additional context about the data’s meaning beyond just barcode or text. This helps determine how to interpret and process the captured information.

predictedLocation
open var predictedLocation: Quadrilateral { get }

Added in version 6.0.0

The predicted location of this field within the image, represented as a quadrilateral with four corner points. These coordinates are in image space and need to be converted to view coordinates before they can be used for UI overlays. When the field’s state is LabelFieldState.unknown, a quadrilateral with all points set to (0,0) is returned.

state
open var state: LabelFieldState { get }

Added in version 6.0.0

The current state of this field in the capture process. This indicates whether the field has been successfully captured, its location has been predicted, or it remains unknown:

isRequired
open var isRequired: Bool { get }

Added in version 6.0.0

Indicates whether this field is required for the label to be considered complete. Returns true for mandatory fields and false for optional fields. This value is determined by the isOptional property set in the corresponding field definition.

barcode
open var barcode: Barcode? { get }

Added in version 6.0.0

The decoded barcode data for this field. This property contains the full barcode information including the decoded data, symbology, and location. Returns null when the field type is not LabelFieldType.barcode or when the barcode hasn’t been successfully captured yet.

text
open var text: String? { get }

Added in version 6.0.0

The recognized text content for this field. This property contains the raw text string extracted through OCR processing. Returns null when the field type is not LabelFieldType.text or when the text hasn’t been successfully captured yet.

asDate
open func asDate() -> LabelDateResult?

Added in version 7.1.0

Attempts to parse the field content as a date using the LabelDateFormat specified in the field definition. Returns a LabelDateResult containing structured date components (day, month, year) if parsing succeeds, or null if the field is not a date field or if parsing fails.

jsonString
open var jsonString: String { get }

Added in version 6.4.0

Returns the JSON representation of the label field.