Custom Text
Defined in library scandit_datacapture_label
- CustomText
class CustomText : TextField
Added in version 7.2.0
Defines a text field with customizable OCR recognition and validation patterns. This field type uses optical character recognition (OCR) to extract text content from labels and can apply regex patterns for content validation.
Use the builder pattern with CustomTextBuilder for convenient configuration, or create instances directly using the various factory methods.
- CustomText(name)
CustomText(String name)
Added in version 7.2.0
Builds a new instance of this class with the provided name.
- setLocationWithRect(rect)
voidsetLocationWithRect(Rect rect)Added in version 7.2.0
Set the location of the text field using a rectangle.
- setLocationWithCoordinates(left, top, right, bottom)
voidsetLocationWithCoordinates(double left, double top, double right, double bottom)Added in version 7.2.0
Set the location of the text field using coordinates.
- setLocationWithType(location)
voidsetLocationWithType(LabelFieldLocationType location)Added in version 7.2.0
Set the location of the text field using a predefined location type.
- dataTypePatterns
List<String> get dataTypePatterns
Added in version 7.2.0
Context-identifying keywords or phrases used to distinguish between fields that may have similar patterns. These patterns help Smart Label Capture identify which field the captured data belongs to when multiple fields could match the same regex pattern.
For example, when a label contains both expiry date and packing date fields, you can use dataTypePatterns like [“exp”, “expiry”] for the expiry date field and [“pack”, “packing”] for the packing date field to help the system correctly identify which date is which.
- name
String get name
Added in version 7.2.0
The unique identifier for this text field within the label definition. This name is used to reference the field when processing captured results and must be unique within the label definition.
- patterns
List<String> get patterns
Added in version 7.2.0
Regular expression patterns used to validate the recognized text content. These patterns allow you to ensure that the captured text matches the expected format for your specific use case.
For example, you can use patterns like [“\d{2}/\d{2}/\d{4}”] for date formats, or [“[A-Z]{2}\d{6}”] for codes that must start with two letters followed by six digits.
- isOptional
bool get isOptional
Added in version 7.2.0
Determines whether this field is required for the label to be considered complete. When set to true, the label can be marked as complete even if this field is not found. When false (mandatory), the label will only be complete when this field is successfully captured.
Optional fields are useful for scenarios where certain information might not always be present on labels, such as promotional text or secondary identifiers.
- location
LabelFieldLocation? get location
Added in version 7.2.0
The spatial location constraint for this text field within the label. This can be used to specify where on the label this field is expected to appear, helping to improve recognition accuracy and speed by focusing the OCR processing area.