Im trying to build an app that uses the Text Recognition that comes with the Firebase_ml_vision package. When i use the Firebase.VisionImage.fromFile(pickedImage) and i download a picture from the internet with text it works perfectly, but when i try to use an image taken with my iPhone Xr camera it does not read the text decently. The output is similar to this:
flutter: 2000 AADAT4A flutter: 2000 AADAT4A flutter: 20000 flutter: 03012 flutter: 2000
this happens when i try to print blocks.text lines or elements.
Does anyone have an ideia how to implement this?
I used this code: (its not all the code but the necessary)
File pickedImage;
List<String> words = [];
Future pickImage() async {
var tempStore =
await ImagePicker.pickImage(source: ImageSource.gallery); //gallery here
setState(() {
pickedImage = tempStore;
isImageLoaded = true;
});
}
Future pickCameraImage() async {
var tempStore =
await ImagePicker.pickImage(source: ImageSource.camera); //camera here
setState(() {
pickedImage = tempStore;
isImageLoaded = true;
});
}
Future readText() async {
FirebaseVisionImage ourImage = FirebaseVisionImage.fromFile(pickedImage);
TextRecognizer recognizeText = FirebaseVision.instance.textRecognizer();
VisionText readText = await recognizeText.processImage(ourImage);
for (TextBlock block in readText.blocks) {
// final Rect boundingBox = block.boundingBox;
// final List<Offset> cornerPoints = block.cornerPoints;
// final String text = block.text;
// final List<RecognizedLanguage> languages = block.recognizedLanguages;
for (TextLine line in block.lines) {
print(block.text);
for (TextElement word in line.elements) {
words.add(word.text);
}
}
} isTextLoaded = true;
}
In the Ui part:
(...)
RaisedButton(
child: Text('Pick an Image'),
onPressed: pickImage,
),
SizedBox(
height: 10.0,
),
RaisedButton(
child: Text('Pick a Camera Image'),
onPressed: pickCameraImage,
),
SizedBox(
height: 10.0,
),
RaisedButton(
child: Text('Read Text'),
onPressed: readText,
),
(...)
I do not have any errors. Anyone with more experience can help me? Thank you