'Flutter app keeps stoping when i'm trying to extarct text from image using google_ml_vision: ^0.0.7
I'm trying to extract Arabic text from an image using google_ml_vision: ^0.0.7, I wrote the function below, but when I call it the app crashed(its crashed in this point await textRecognizer.processImage(visionImage)) without providing any logs the image path is correct but it still didn't work
Future _extarctArabicTexFromImage() async {
try {
// final File imageFile = File(imgPath);
final GoogleVisionImage visionImage =
GoogleVisionImage.fromFilePath(imgPath);
final TextRecognizer textRecognizer =
GoogleVision.instance.textRecognizer();
late VisionText visionText;
try {
visionText = await textRecognizer.processImage(visionImage);
} catch (e) {
print(e.toString());
}
// String text = visionText.text;
for (var block in visionText.blocks) {
final List<RecognizedLanguage> languages = block.recognizedLanguages;
for (var line in block.lines) {
for (var textElement in line.elements) {
txt = txt + " " + textElement.text.toString();
}
txt = txt + '\n';
}
}
} catch (e) {
print(e.toString());
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
