receipt_recognition 0.0.1 copy "receipt_recognition: ^0.0.1" to clipboard
receipt_recognition: ^0.0.1 copied to clipboard

A receipt recognizer based on Google's ML Kit.

๐Ÿ“ท receipt_recognition #

A Flutter package for scanning and extracting structured data from supermarket receipts using Google's ML Kit. Ideal for building expense tracking apps, loyalty programs, or any system needing receipt parsing.


โœจ Features #

  • ๐Ÿงพ Detect and extract text from printed receipts
  • ๐Ÿ›’ Optimized for typical supermarket layouts
  • ๐Ÿ” Identifies line items, totals, and store names
  • โšก Fast and efficient ML Kit text recognition
  • ๐Ÿ“ฑ Works on Android and iOS
  • ๐Ÿ”ง Easy API with callback support

๐Ÿš€ Getting Started #

Installation #

Add to your pubspec.yaml:

dependencies:
  receipt_recognition: ^<latest_version>

Then run:

flutter pub get

Platform Setup #

Android

Update AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

iOS

Update Info.plist:

<key>NSCameraUsageDescription</key>
<string>Camera access is needed to scan receipts.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo library access is needed to select receipt images.</string>

๐Ÿ“ฆ Basic Usage #

import 'package:receipt_recognition/receipt_recognition.dart';
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';

final receiptRecognizer = ReceiptRecognizer(
  scanTimeout: Duration(seconds: 10),
  onScanTimeout: () {
    print('Scan timed out.');
  },
  onScanComplete: (receipt) {
    print('Scan complete! Store: ${receipt.company?.formattedValue}');
    print('Total: ${receipt.sum?.formattedValue}');
  },
  onScanUpdate: (partial) {
    print('In-progress scan: ${partial.positions.length} items detected so far.');
  },
);

// Load an image (from file, camera, etc.)
final inputImage = InputImage.fromFilePath('path/to/receipt.jpg');

// Process the image
final receipt = await receiptRecognizer.processImage(inputImage);

if (receipt != null) {
  print('Store: ${receipt.company?.formattedValue}');
  for (final item in receipt.positions) {
    print('Product: ${item.product.formattedValue}, Price: ${item.price.formattedValue}');
  }
  print('Total: ${receipt.sum?.formattedValue}');
}

๐ŸŽฅ Advanced Example: Video Feed Integration #

For an advanced use case, we provide an example of using this package with a video feed. You can integrate it with a camera feed (via a package like camera), and continuously scan receipts in real time.

Refer to the example app for an implementation that uses live camera data to recognize and process receipts as they appear in the frame.


๐Ÿงน Clean Up #

await receiptRecognizer.close();

๐Ÿง  Model Overview #

Class Description
RecognizedReceipt Represents a full parsed receipt with items, sum, and store name.
RecognizedPosition A single line item on the receipt: product + price.
RecognizedEntity<T> Generic wrapper for parsed values from raw text.
RecognizedCompany Specialized entity for the store name.
RecognizedAmount / RecognizedSum Numerical values like prices and total.
formattedValue Nicely formatted display value.

๐Ÿงพ Model Structure #

RecognizedReceipt
โ”œโ”€โ”€ company: RecognizedCompany
โ”‚   โ””โ”€โ”€ value: String (e.g., "Walmart")
โ”œโ”€โ”€ sum: RecognizedSum
โ”‚   โ””โ”€โ”€ value: num (e.g., 23.45)
โ””โ”€โ”€ positions: List<RecognizedPosition>
     โ”œโ”€โ”€ RecognizedPosition
     โ”‚   โ”œโ”€โ”€ product: RecognizedEntity<String>
     โ”‚   โ”‚   โ””โ”€โ”€ value: "Milk"
     โ”‚   โ””โ”€โ”€ price: RecognizedAmount
     โ”‚       โ””โ”€โ”€ value: 2.49
     โ””โ”€โ”€ ...

๐Ÿ”ฎ Roadmap #

  • โŒ Product name normalization and categorization
  • โŒ Tax and discount detection
  • โŒ Smart OCR region selection
  • โŒ Multi-language receipt support

๐Ÿค Contributing #

Contributions, suggestions, and bug reports are welcome! Feel free to open an issue or PR.


๐Ÿ“„ License #

This package is released under the MIT License.

3
likes
0
points
308
downloads

Publisher

unverified uploader

Weekly Downloads

A receipt recognizer based on Google's ML Kit.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, google_mlkit_text_recognition, intl

More

Packages that depend on receipt_recognition