ocr_scan 0.0.4
ocr_scan: ^0.0.4 copied to clipboard
OCR scan library for Flutter. It can scan text form zones in preview.
OCR Scan #
OCR scan library for Flutter. It can scan text from zones in preview.
[Demo]
Requirements #
Since thus package uses ML Kit check requirements before running the package in project.
How to use #
- Add
ocr_scanto yourpubspec.yaml - Import the desired package or class.
import 'package:ocr_scan/ocr_scan.dart';
Widget buildPreview(BuildContext context) {
final ScaffoldMessengerState messenger = ScaffoldMessenger.of(context);
return OcrScanPreview(
ocrDuration: const Duration(milliseconds: 5000),
ocrProcess: ocrProcess,
ocrZonePainter: OcrScanZonePainter(
elements: const [
OcrScanZone(
Rect.fromLTWH(40, 200, 1200, 100),
text: TextSpan(
text: 'Zone 1: TOP',
style: TextStyle(backgroundColor: Colors.red),
),
paintingColor: Colors.red,
), // Zone1 TOP
OcrScanZone(
Rect.fromLTWH(40, 400, 1200, 100),
text: TextSpan(
text: 'Zone 2: BOTTOM',
style: TextStyle(backgroundColor: Colors.green),
),
paintingColor: Colors.green,
),
],
previewSize: const Size(1280, 720),
),
onOcrTextLine: ((int, List<TextLine>) value) {
messenger.showSnackBar(SnackBar(
duration: const Duration(milliseconds: 2000),
content: Text(
value.$2.fold(
'Rect ${value.$1 + 1} - Length ${value.$2.length}:',
(String pre, TextLine e) => '$pre\n${e.text}',
),
),
));
},
);
}
Contributing #
Contributions are always welcome!
Please check out our contribution guidelines for more details.
License #
ORC Scan is licensed under the MIT License.