This commit is contained in:
Hamza Aleghwairyeen
2023-10-24 14:56:11 +03:00
parent 9a970a5b23
commit 074fe6838b
7 changed files with 64 additions and 46 deletions

View File

@@ -22,6 +22,7 @@ class TextExtractionController extends GetxController {
String getTextAsJSON(String text) {
final json = {
'text': text,
'num_lines': text.split('\n').length,
};
return jsonEncode(json);
@@ -61,7 +62,7 @@ class TextExtractionController extends GetxController {
textBlocks.toString(); // Convert the extracted text to JSON.
// Print the JSON to the console.
print(textBlocks);
print(jsonText);
update();
// print(text);
} catch (e) {
@@ -72,35 +73,8 @@ class TextExtractionController extends GetxController {
}
}
// class TesseractController extends GetxController {
// String text = '';
// bool scanning = false;
// Future<void> extractTextFromImage() async {
// scanning = true;
// update();
// // Get the image from the image picker
// final ImagePicker picker = ImagePicker();
// final XFile? image = await picker.pickImage(source: ImageSource.gallery);
// // If an image was selected, extract the text from it
// if (image != null) {
// var watch = Stopwatch()..start();
// text = await TesseractLatest.extractText(image.path);
// scanning = false;
// update();
// print('Scanning took ${watch.elapsedMilliseconds} ms');
// }
// }
// }
// 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 {
class TextMLGoogleRecognizerController extends GetxController {
@override
void onInit() {
scanText();
@@ -121,7 +95,7 @@ class TextRecognizerController extends GetxController {
Future<void> scanText() async {
// Pick an image from the camera or gallery
final XFile? image =
await _imagePicker.pickImage(source: ImageSource.gallery);
await _imagePicker.pickImage(source: ImageSource.camera);
// If no image was picked, return
if (image == null) {