Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get scanned text in ios #3

Open
Arjun47B opened this issue Dec 3, 2019 · 2 comments
Open

Not able to get scanned text in ios #3

Arjun47B opened this issue Dec 3, 2019 · 2 comments

Comments

@Arjun47B
Copy link

Arjun47B commented Dec 3, 2019

No description provided.

@DaemonLoki
Copy link
Owner

Hey @Arjun47B thanks for bringing this issue up.

If you could be so kind as to provide me the error message that is occurring for you then I'll have a look and see if I can be of help! :)

@Arjun47B
Copy link
Author

Arjun47B commented Dec 3, 2019

void onTakePictureButtonPressed() {
print('onTakePictureButtonPressed call');
takePicture().then((String filePath) {
if (mounted) {
if (filePath != null) {
print('value ${filePath}');
setState(() {
filePicImage = File(filePath);
justWait(3, filePath);
});
}
}
});
}

Future takePicture() async {
if (!controller.value.isInitialized) {
// showInSnackBar('Error: select a camera first.');
return null;
}
final Directory extDir = await getApplicationDocumentsDirectory();
print('Directory ${extDir.path}');
final String dirPath = '${extDir.path}/Pictures/flutter_test';
print('Directory dirPath ${dirPath}');
await Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/${timestamp()}.jpg';
if (controller.value.isTakingPicture) {
// A capture is already pending, do nothing.
return null;
}

try {
  await controller.takePicture(filePath);
} on CameraException catch (e) {
  // _showCameraException(e);
  return null;
}
return filePath;

}

getText(File imgCroped) async {
print('getText called ${imgCroped.path}');
final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(imgCroped);
final TextRecognizer textRecognizer = FirebaseVision.instance.textRecognizer();
final VisionText visionText = await textRecognizer.processImage(visionImage);
String text = visionText.text;
print('Text ${text}');
print('Text ${visionText.blocks}');
List finalArrayString = List();
for (TextBlock block in visionText.blocks) {
final Rect boundingBox = block.boundingBox;
final List cornerPoints = block.cornerPoints;
final String text = block.text;
print('block Text ${text}');
finalArrayString.add(text);
final List languages = block.recognizedLanguages;
for (TextLine line in block.lines) {
// Same getters as TextBlock
for (TextElement element in line.elements) {
// Same getters as TextBlock
print('element Text ${element.text}');
}
}
}
print('all string get array ${finalArrayString}');
}

Step 1 - I am using CameraController for pic image.
Step 2 - Picked image from Camera Controller is passed to 'FirebaseVisionImage' and try to get VisionText .
Above code is working fine in android.when i am trying to scan in ios, its not working.i am getting
blank visionText.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants