This commit is contained in:
Hamza-Ayed
2023-10-23 13:21:41 +03:00
parent 1b5bbab35f
commit e9738296df
14 changed files with 380 additions and 300 deletions

View File

@@ -1,37 +0,0 @@
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:google_ml_kit/google_ml_kit.dart';
class TextRecognizerController extends GetxController {
// The ImagePicker instance
final ImagePicker _imagePicker = ImagePicker();
// The GoogleMlKit TextRecognizer instance
final TextRecognizer _textRecognizer = TextRecognizer();
// The scanned text
String? scannedText;
// Picks an image from the camera or gallery and extracts the text
Future<void> scanText() async {
// Pick an image from the camera or gallery
final XFile? image =
await _imagePicker.pickImage(source: ImageSource.gallery);
// If no image was picked, return
if (image == null) {
return;
}
// Recognize the text in the image
final RecognizedText recognizedText =
await _textRecognizer.processImage(image as InputImage);
// Extract the scanned text
scannedText = recognizedText.text;
// Update the UI
update();
}
}