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 template artifacts, 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: [Artifact(...)],
);

Key features:

  • Supports JSON serialization/deserialization
  • Stores multiple template artifacts 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<Artifact> 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

averageColHistogram → List<double>
Returns the average column histogram across all template matrices.
no setter
averageRowHistogram → List<double>
Returns the average row histogram across all template matrices.
no setter
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<Artifact>
List of matrices representing this character's visual pattern.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

histogramSimilarity(List<int> inputColHist, List<int> inputRowHist) → double
Computes histogram similarity between this template and an input artifact.
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

Constants

templateHeight → const int
The height of the character template.
templateWidth → const int
The width of the character template.