Files
receipity/lib/models/ocr_element.dart
T
2026-09-02 12:35:41 +02:00

39 lines
894 B
Dart

/// One OCR text fragment with pixel bounding box on the receipt image.
library;
class OcrElement {
const OcrElement({
required this.text,
required this.left,
required this.top,
required this.right,
required this.bottom,
});
final String text;
final double left;
final double top;
final double right;
final double bottom;
double get centerX => (left + right) / 2;
double get centerY => (top + bottom) / 2;
double get height => (bottom - top).abs();
double get width => (right - left).abs();
}
/// All positioned elements from one ML Kit recognition pass.
class OcrDocument {
const OcrDocument({
required this.elements,
required this.imageWidth,
required this.imageHeight,
required this.flattenedText,
});
final List<OcrElement> elements;
final double imageWidth;
final double imageHeight;
final String flattenedText;
}