在我的 android 应用程序中,我为 ocr 运行 tesseract 引擎。我已经测试了很长时间,它工作正常。今天我收到一个错误:致命信号 11,它似乎在这个函数 baseApi.init() 中。我使用两种语言 eng+ell。我能做些什么来解决这个问题?我的日志文件在这里:
09-09 17:40:24.710: D/dalvikvm(7446): GC_FOR_ALLOC freed 601K, 9% free 17303K/18972K, paused 25ms, total 28ms
09-09 17:40:24.790: I/dalvikvm-heap(7446): Grow heap (frag case) to 54.495MB for 38340880-byte allocation
09-09 17:40:24.810: D/dalvikvm(7446): GC_FOR_ALLOC freed 11K, 3% free 54733K/56416K, paused 22ms, total 22ms
09-09 17:40:24.840: D/dalvikvm(7446): GC_CONCURRENT freed 0K, 3% free 54733K/56416K, paused 3ms+13ms, total 28ms
09-09 17:40:25.150: D/dalvikvm(7446): GC_FOR_ALLOC freed 61K, 4% free 54681K/56416K, paused 13ms, total 13ms
09-09 17:40:25.190: I/dalvikvm-heap(7446): Grow heap (frag case) to 90.998MB for 38340880-byte allocation
09-09 17:40:25.210: D/dalvikvm(7446): GC_FOR_ALLOC freed <1K, 2% free 92123K/93860K, paused 15ms, total 15ms
09-09 17:40:25.250: D/dalvikvm(7446): GC_CONCURRENT freed <1K, 2% free 92124K/93860K, paused 3ms+13ms, total 42ms
09-09 17:40:38.323: D/dalvikvm(7446): Trying to load lib /data/app-lib/com.geo.myapp_1r-1/liblept.so 0x41ffcc90
09-09 17:40:38.323: D/dalvikvm(7446): Added shared lib /data/app-lib/com.geo.myapp_1r-1/liblept.so 0x41ffcc90
09-09 17:40:38.323: D/dalvikvm(7446): Trying to load lib /data/app-lib/com.geo.myapp_1r-1/libtess.so 0x41ffcc90
09-09 17:40:38.353: D/dalvikvm(7446): Added shared lib /data/app-lib/com.geo.myapp_1r-1/libtess.so 0x41ffcc90
09-09 17:40:38.353: V/OcrAsyncTask(7446): eng+ell
09-09 17:40:38.353: A/libc(7446): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 7568 (AsyncTask #4)
09-09 17:40:38.363: D/ProgressBar(7446): setProgress = 0
09-09 17:40:38.363: D/ProgressBar(7446): setProgress = 0, fromUser = false
09-09 17:40:38.363: D/ProgressBar(7446): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
09-09 17:40:38.403: D/ProgressBar(7446): setProgress = 25
09-09 17:40:38.403: D/ProgressBar(7446): setProgress = 25, fromUser = false
09-09 17:40:38.403: D/ProgressBar(7446): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
09-09 17:40:48.593: I/Choreographer(7446): Skipped 608 frames! The application may be doing too much work on its main thread.
更新:我再次运行它,现在日志文件显示:
09-09 18:07:17.113: D/ProgressBar(9018): updateDrawableBounds: left = 0
09-09 18:07:17.113: D/ProgressBar(9018): updateDrawableBounds: top = 0
09-09 18:07:17.113: D/ProgressBar(9018): updateDrawableBounds: right = 834
09-09 18:07:17.113: A/libc(9018): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 9082 (AsyncTask #1)
09-09 18:07:17.113: D/ProgressBar(9018): updateDrawableBounds: bottom = 48
09-09 18:07:17.113: D/ProgressBar(9018): updateDrawableBounds: mProgressDrawable.setBounds()
可能与 AsyncTask 和 UI 线程有关的问题?可以肯定的是,它总是停留在执行 baseApi.init() 的 25%。
第二次更新:好吧,我在不同的类中运行 OCR 的代码,而不使用 AsyncTask 来查看问题是否来自 AsyncTask,它告诉我它不是来自 AsyncTask。问题来自 baseApi.init()。这是我的代码:
TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init(languagePath, languageCode);
baseApi.setImage(bitmap);
recognizedText = baseApi.getUTF8Text();
baseApi.end();