Captured Field

Defined under the namespace Scandit.Datacapture.Label

LabelField
class LabelField

Added in version 8.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:

capturedFields.forEach(field => {
    const value = field.barcode?.data ?? field.text ?? formatDate(field.date);
    console.log(`${field.name}: ${value}`);
});
name
get name(): string

Added in version 8.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
get type(): LabelFieldType

Added in version 8.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:

predictedLocation
get predictedLocation(): Quadrilateral

Added in version 8.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
get state(): LabelFieldState

Added in version 8.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
get isRequired(): boolean

Added in version 8.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
get barcode(): Barcode | null

Added in version 8.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
get text(): string | null

Added in version 8.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()
asDate(): LabelDateResult | null

Added in version 8.0.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.