CharacterDefinition class
A class that defines the characteristics and properties of a single character for OCR processing.
The CharacterDefinition class stores various attributes of a character including its visual representation through matrices, structural properties like enclosures, and categorical information such as whether it's a letter, digit, or punctuation mark.
Example:
final charDef = CharacterDefinition(
character: 'A',
isLetter: true,
matrices: [Matrix(...)],
);
Key features:
- Supports JSON serialization/deserialization
- Stores multiple matrix representations of the character
- Tracks character properties like enclosures and line presence
- Categorizes characters (letter, digit, punctuation, etc.)
- Maintains standard template dimensions (60x40)
This class is fundamental to the Textify OCR system, providing the template definitions used for character recognition and matching.
Constructors
-
CharacterDefinition({required String character, int enclosures = 0, bool isAmount = false, bool isDate = false, bool isDigit = false, bool isLetter = false, bool isPunctuation = false, bool lineLeft = false, bool lineRight = false, List<
Matrix> matrices = const []}) - Creates a new CharacterDefinition instance.
-
CharacterDefinition.fromJson(Map<
String, dynamic> json) -
Creates a CharacterDefinition from a JSON map.
factory
- CharacterDefinition.fromJsonString(String jsonString)
-
Creates a CharacterDefinition from a JSON string.
factory
Properties
- character → String
-
The character being defined.
final
- enclosures → int
-
The number of enclosures for this character.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAmount → bool
-
Indicates if this character is used in monetary amounts.
final
- isDate → bool
-
Indicates if this character is commonly used in date representations.
final
- isDigit → bool
-
Indicates if this character is a numerical digit.
final
- isLetter → bool
-
Indicates if this character is an alphabetic letter.
final
- isPunctuation → bool
-
Indicates if this character is a punctuation mark.
final
- lineLeft → bool
-
Indicates if the character has a left vertical line as part of its shape.
final
- lineRight → bool
-
Indicates if the character has a right vertical line as part of its shape.
final
-
matrices
→ List<
Matrix> -
List of matrices representing this character's visual pattern.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts this CharacterDefinition to a JSON map.
-
toJsonString(
) → String - Converts this CharacterDefinition to a JSON string.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- templateHeight ↔ int
-
The height of the character template.
getter/setter pair
- templateWidth ↔ int
-
The width of the character template.
getter/setter pair