I am having an issue with Flutter firebase_ml_vision. When testing on an iPad Mini 2 (seen this on android in the past), no text is detected when taking the photo in Portrait. It seems to work in landscape. I had the exact same issue when i was writing the original app in Native Android (i since decided to make it in Flutter/Dart)
I have spent a few hours now trying to figure this out. This seems to be a known issue but with no general consensus on the solution.
The closest i got to it working was with This SO fixExifRotation() function however the text that is read is scrambled.
Has anyone come across this issue and found a working solution?
Future<String> takePicture() async {
File imageFile = await ImagePicker.pickImage(
source: ImageSource.camera,
imageQuality: 100,
);
if (imageFile == null) {
return null;
}
final appDir = await syspaths.getApplicationDocumentsDirectory();
final fileName = path.basename(rotatedFile.path);
final savedImage = await rotatedFile.copy('${appDir.path}/$fileName');
return '${appDir.path}/$fileName';
}
...
Future<MLResult> processText({@required BuildContext context,String imageFilePath}) async {
final FirebaseVisionImage visionImage =
FirebaseVisionImage.fromFilePath(imageFilePath);
final TextRecognizer _recognizer = FirebaseVision.instance.textRecognizer();
final VisionText readText = await _recognizer.processImage(visionImage);
var blocks = readText.blocks;
if (blocks.length == 0) {
//*** THIS IF BLOCK IS EXECUTED - no text is detected by ML Vision.
}
}
imagePath = await Vision.takePicture();
Vision.processText(
context: context,
imageFilePath: imagePath,
).then((value) {..});