first commit
This commit is contained in:
commit
e630f2a3ec
80 changed files with 3889 additions and 0 deletions
21
lib/services/ocr_service.dart
Normal file
21
lib/services/ocr_service.dart
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
|
||||
|
||||
/// Thin wrapper around ML Kit's on-device text recognizer so the rest of
|
||||
/// the app depends on a single, easily-swappable entry point rather than
|
||||
/// the ML Kit API directly.
|
||||
class OcrService {
|
||||
final TextRecognizer _recognizer =
|
||||
TextRecognizer(script: TextRecognitionScript.latin);
|
||||
|
||||
Future<String> recognizeText(File imageFile) async {
|
||||
final inputImage = InputImage.fromFile(imageFile);
|
||||
final result = await _recognizer.processImage(inputImage);
|
||||
return result.text;
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_recognizer.close();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue