google_ml_kit_flutter icon indicating copy to clipboard operation
google_ml_kit_flutter copied to clipboard

google_mlkit_text_recognition: ^0.13.1 unable to return OCR of arabic verse.

Open adnankhan74444 opened this issue 1 year ago • 1 comments

Describe your issue. If applicable, add screenshots to help explain your problem.

Future<void> recognizeArabicText(File imageFile) async {
  final inputImage = InputImage.fromFile(imageFile);
  final textRecognizer = TextRecognizer(script: TextRecognitionScript.latin);

  try {
    final recognizedTextResult = await textRecognizer.processImage(inputImage);
    print('RecognizedTextResult: ${recognizedTextResult.text}');
  } catch (e) {
    print('Error during text recognition: $e');
  } finally {
    textRecognizer.close();
  }
}

Future<File> getImageFileFromAssets(String path) async {
  final byteData = await rootBundle.load('assets/$path');
  final file = File('${(await getTemporaryDirectory()).path}/$path');
  await file.create(recursive: true);
  await file.writeAsBytes(byteData.buffer
      .asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
  return file;
}

Future<void> getOCRText() async {
  var assetsFile = await getImageFileFromAssets('002.png');
  print('Loaded image: ${assetsFile.path}, Size: ${await assetsFile.length()} bytes');
  await recognizeArabicText(assetsFile);
}

recognizedTextResult.text always return empty.

002

Steps to reproduce.

Future<void> recognizeArabicText(File imageFile) async {
  final inputImage = InputImage.fromFile(imageFile);
  final textRecognizer = TextRecognizer(script: TextRecognitionScript.latin);

  try {
    final recognizedTextResult = await textRecognizer.processImage(inputImage);
    print('RecognizedTextResult: ${recognizedTextResult.text}');
  } catch (e) {
    print('Error during text recognition: $e');
  } finally {
    textRecognizer.close();
  }
}

Future<File> getImageFileFromAssets(String path) async {
  final byteData = await rootBundle.load('assets/$path');
  final file = File('${(await getTemporaryDirectory()).path}/$path');
  await file.create(recursive: true);
  await file.writeAsBytes(byteData.buffer
      .asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
  return file;
}

Future<void> getOCRText() async {
  var assetsFile = await getImageFileFromAssets('002.png');
  print('Loaded image: ${assetsFile.path}, Size: ${await assetsFile.length()} bytes');
  await recognizeArabicText(assetsFile);
}

recognizedTextResult.text always return empty.

002

What is the expected result?

It should return the result

Did you try our example app?

Yes

Is it reproducible in the example app?

Yes

Reproducible in which OS?

Android, iOS and Android

Flutter/Dart Version?

No response

Plugin Version?

google_mlkit_text_recognition: ^0.13.1

adnankhan74444 avatar Sep 30 '24 06:09 adnankhan74444

@bensonarafat any update on this?

adnankhan74444 avatar Oct 13 '24 07:10 adnankhan74444

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Nov 12 '24 12:11 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Nov 26 '24 12:11 github-actions[bot]

@bensonarafat any update on this?

adnankhan74444 avatar Nov 26 '24 12:11 adnankhan74444

Any solution for this? any one

Mikeruss1418 avatar Feb 19 '25 03:02 Mikeruss1418