khjde1207 / tesseract_ocr

Tesseract OCR for flutter
BSD 3-Clause "New" or "Revised" License
62 stars 31 forks source link

stop work and give error #30

Open islom9797 opened 1 year ago

islom9797 commented 1 year ago

Hello,I have a problem during use tesseract recognize of text ,app stopping during or after reading text and give some error:

Thread[6,tid=23169,WaitingInMainSignalCatcherLoop,Thread*=0xb4000075facbdad0,peer=0x13680000,"Signal Catcher"]: reacting to signal 3 I/etectionexampl(23157): I/etectionexampl(23157): Wrote stack traces to tombstoned F/crash_dump64(24102): crash_dump.cpp:536] failed to attach to thread 647: Permission denied F/crash_dump64(24117): crash_dump.cpp:536] failed to attach to thread 884, already traced by 0 () please give some suggestion thanks

khjde1207 commented 1 year ago

Please provide the error file. Or send it to khjde1207@gmail.com. thank you

fahad-whizpool commented 1 year ago

Hi I am facing the same error. Any solution.... here is the complete output in Debug Console....... I/Quality (18987): stackInfo :----- pid 18987 at 2023-02-08 10:22:16.703 -----;Cmd line: com.whizpool.warrantyapp;"main" prio=5 tid=2 RUNNABLE sysTid=18987; at com.googlecode.tesseract.android.TessBaseAPI.nativeGetUTF8Text(Native Method); at com.googlecode.tesseract.android.TessBaseAPI.getUTF8Text(TessBaseAPI.java:696); at io.paratoner.flutter_tesseract_ocr.MyRunnable.run(FlutterTesseractOcrPlugin.java:107); at io.paratoner.flutter_tesseract_ocr.FlutterTesseractOcrPlugin.onMethodCall(FlutterTesseractOcrPlugin.java:75); at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262); at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295); at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319); at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12); at android.os.Handler.handleCallback(Handler.java:938); at android.os.Handler.dispatchMessage(Handler.java:99); at android.os.Looper.loopOnce(Looper.java:233); at android.os.Looper.loop(Looper.java:344); at android.app.ActivityThread.main(ActivityThread.java:8212); at java.lang.reflect.Method.invoke(Native Method); at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584); at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034); I/Quality (18987): stackInfo :----- pid 18987 at 2023-02-08 10:22:18.223 -----;Cmd line: com.whizpool.warrantyapp;"main" prio=5 tid=2 RUNNABLE sysTid=18987; at com.googlecode.tesseract.android.TessBaseAPI.nativeGetUTF8Text(Native Method); at com.googlecode.tesseract.android.TessBaseAPI.getUTF8Text(TessBaseAPI.java:696); at io.paratoner.flutter_tesseract_ocr.MyRunnable.run(FlutterTesseractOcrPlugin.java:107); at io.paratoner.flutter_tesseract_ocr.FlutterTesseractOcrPlugin.onMethodCall(FlutterTesseractOcrPlugin.java:75); at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262); at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295); at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319); at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12); at android.os.Handler.handleCallback(Handler.java:938); at android.os.Handler.dispatchMessage(Handler.java:99); at android.os.Looper.loopOnce(Looper.java:233); at android.os.Looper.loop(Looper.java:344); at android.app.ActivityThread.main(ActivityThread.java:8212); at java.lang.reflect.Method.invoke(Native Method); at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584); at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034); I/ool.warrantyap(18987): Thread[2,tid=19034,WaitingInMainSignalCatcherLoop,Thread*=0xb400006f6042c000,peer=0x134401f8,"Signal Catcher"]: reacting to signal 3 I/ool.warrantyap(18987): I/ool.warrantyap(18987): Wrote stack traces to tombstoned F/crash_dump64(19936): crash_dump.cpp:487] failed to attach to thread 581: Permission denied F/crash_dump64(20049): crash_dump.cpp:487] failed to attach to thread 628: Permission denied Lost connection to device. Exited

khjde1207 commented 1 year ago

Does the problem always occur in the same file? can you provide the file?

fahad-whizpool commented 1 year ago

where i call the FlutterTess right after the line below. _resultString = await FlutterTesseractOcr.extractText( imagePath, args: { "preserve_interword_spaces": "1", }, );

khjde1207 commented 1 year ago

Can you provide a sample? I just tried updating kotlin_version and dependencies.

fahad-whizpool commented 1 year ago

Here is the complete method where that line of code is called.. Future loadWithIdOrCreateNewWithImage( int id, String imagePath) async { if (id > 0) { try { _warrantyCard = await DBManager.instance.loadWarrantyCardById(id); _oldWarrantyCard.copyFrom(_warrantyCard); Future.delayed(Duration(milliseconds: 500), () => _warrantyCardController.add(_warrantyCard)); } catch (e) { Future.delayed(Duration(milliseconds: 500), () => _warrantyCardController.addError(e)); } } else if (imagePath != null && imagePath.isNotEmpty) { //var result = await TessPlugin.getStringFromImage(imagePath); String? _resultString;

  try {
    // //old code
    // _resultString = await SimpleOcrPlugin.performOCR(imagePath);
    debugPrint("beofre ocr flutterr...............");
    //*************************new code********************
    _resultString = await FlutterTesseractOcr.extractText(
      imagePath,
      args: {
        "preserve_interword_spaces": "1",
      },
    );
  } catch (e) {
    debugPrint("FlutterTesseractOcrError=$e");
    _warrantyCard.setDescription =
        "error in recognizing the image / photo => ${e.toString()}";
  }
  final _decodedResult = _resultString;
  if (_resultString != null || _resultString!.isNotEmpty) {
    try {
      print('Print result before parse****');
      // print(jsonDecode(_resultString)['text']);
      final phoneString = _parsePhoneNoIfAny(_resultString);
      //debugPrint("phoneNo=**********>$phoneString");
      _resultString = _parseResultDate(_resultString);
    } catch (e) {
      debugPrint("Error Occured=$e");
      rethrow;
    }
    _resultString = _resultString.substring(
      24,
    );

    print(_resultString);
    _warrantyCard.setDescription = _resultString;

    _warrantyCard.setCardNum = _parseCardNumber(_decodedResult!);
    final c = _parseCardNumber(_decodedResult);

    debugPrint("cardNo=======>$c");
  } else {
    _warrantyCard.setDescription = "No Result";
  }

  _warrantyCard.setImagePathWithExtension = imagePath;
  Future.delayed(Duration(milliseconds: 500),
      () => _warrantyCardController.add(_warrantyCard));
} else {
  throw 'Both id and imagePath were illegal.';
}

return _warrantyCard;

}

khjde1207 commented 1 year ago

Is imagePath a local path? flutter_file_dialog allows you to save that image elsewhere. can you give me this image? https://pub.dev/packages/flutter_file_dialog

jipika commented 8 months ago

imagePath 是本地路径吗? flutter_file_dialog 允许您将图像保存在其他位置。 您提供我这张图片吗? https://pub.dev/packages/flutter_file_dialog

image