ocr_scan 0.1.3
ocr_scan: ^0.1.3 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 ScanPreview(
scanProcess: process,
scanDuration: const Duration(milliseconds: 2000 * 3),
textRecognizerConfig: TextRecognizerConfig(
zonePainter: ZonePainter(
elements: [
const Zone(
Rect.fromLTWH(40, 100, 1200, 100),
text: TextSpan(
text: 'Zone 1: TOP',
style: TextStyle(backgroundColor: Colors.red),
),
paintingColor: Colors.red,
), // Zone1 TOP
const Zone(
Rect.fromLTWH(40, 500, 1200, 100),
text: TextSpan(
text: 'Zone 2: BOTTOM',
style: TextStyle(backgroundColor: Colors.green),
),
paintingColor: Colors.green,
),
],
),
onTextLine: ((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}',
),
),
));
},
),
barcodeScannerConfig: BarcodeScannerConfig(
zonePainter: ZonePainter(
elements: [
const Zone(
Rect.fromLTWH(40, 250, 1200, 200),
text: TextSpan(
text: 'Zone 3: CENTER',
style: TextStyle(backgroundColor: Colors.yellow),
),
paintingColor: Colors.yellow,
),
],
),
onBarcode: ((int, List<Barcode>) value) {
messenger.showSnackBar(SnackBar(
duration: const Duration(milliseconds: 2000),
content: Text(
value.$2.fold(
'Rect 3 - Length ${value.$2.length}:',
(String pre, Barcode e) => '$pre\n${e.displayValue}',
),
),
));
},
),
);
}
Contributing #
Contributions are always welcome!
Please check out our contribution guidelines for more details.
License #
ORC Scan is licensed under the MIT License.