improve parsing 2
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user