在tess-two中调用end()方法导致应用程序崩溃

时间:2015-06-26 12:31:50

标签: android tesseract tess-two

我正在使用tess-two没有问题,但是当我调用TessBaseAPI.end()时,应用程序崩溃了。显示此日志消息。

06-26 09:06:18.065   2347-14702/? I/ActivityManager﹕ Killing proc 14146:br.com.nglauber.app.ocr/u0a10163: force stop br.com.nglauber.app.ocr
06-26 09:06:18.065   2347-14702/? W/ActivityManager﹕ Force removing ActivityRecord{431661d8 u0 br.com.nglauber.app.ocr/br.com.nglauber.app.payoff.PayoffActivity}: app died, no saved state
06-26 09:06:18.230    2347-2461/? D/CrashAnrDetector﹕ Build: samsung/m0ub/m0:4.3/JSS15J/I9300UBUGNL1:user/release-keys
    Hardware: smdk4x12
    Revision: 12
    Bootloader: I9300UBUGNL1
    Radio: unknown
    Kernel: Linux version 3.0.31-2812098 (se.infra@SWDA2610) (gcc version 4.4.3 (GCC) ) #1 SMP PREEMPT Tue Dec 16 22:20:53 KST 2014
    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'samsung/m0ub/m0:4.3/JSS15J/I9300UBUGNL1:user/release-keys'
    Revision: '12'
    pid: 14146, tid: 14663, name: Thread-1376  >>> br.com.nglauber.app.ocr <<<
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 000000a8
    r0 5ee9d660  r1 00000020  r2 00000001  r3 00000000
    r4 0000006f  r5 64ed19c8  r6 5ee9ce90  r7 60cea2f8
    r8 60bafa48  r9 64f3c868  sl 00000018  fp 000000fe
    ip 60eac448  sp 64362390  lr 607a9da7  pc 607a9d9e  cpsr 88000030
    d0  01a56e1fc2f8f359  d1  3f11155ab300621e
    d2  3f1114d75eadfb55  d3  3fe188c800000000
    d4  407f400000000000  d5  3f71c92245382f5d
    d6  3f71c92245382f5d  d7  000000fe3f7ee36e
    d8  000000003f800000  d9  0000000000000000
    d10 0000000000000000  d11 0000000000000000
    d12 0000000000000000  d13 0000000000000000
    d14 0000000000000000  d15 0000000000000000
    d16 403ec1e0872ff28d  d17 bfa2b4442c6a6c2f
    d18 3e64852cd8c08bf7  d19 3fc4c82f9669a9cd
    d20 3ca1a62633145c07  d21 3fc249249976c1af
    d22 bfbc71c70ac3a12e  d23 3fb745cdd03b7830
    d24 bfb3b0f2b9082f3f  d25 3fb10d66a8fbcae1
    d26 bfadde2d5edd7fa8  d27 3fa97b4b29cee400
    d28 3f90ad3ae322da11  d29 3f29a0080575b857
    d30 3fd555555b323d4d  d31 bfc99999a2b7aa58
    scr 68000093
    backtrace:
    #00  pc 000bfd9e  /data/app-lib/br.com.nglauber.app.ocr-1/libtess.so (tesseract::Classify::ComputeCharNormArrays(FEATURE_STRUCT*, INT_TEMPLATES_STRUCT*, unsigned char*, unsigned char*)+73)
    #01  pc 000c0c7f  /data/app-lib/br.com.nglauber.app.ocr-1/libtess.so (tesseract::Classify::CharNormTrainingSample(bool, int, tesseract::TrainingSample const&, GenericVector<tesseract::UnicharRating>*)+210)
    stack:
    64362350  00000000
    64362354  0000006e
    64362358  5ee9ce90
    6436235c  64f3c868
    64362360  60bafa48
    64362364  000000ff
    64362368  64f3c868
    6436236c  607b154f  /data/app-lib/br.com.nglauber.app.ocr-1/libtess.so (tesseract::Classify::ComputeIntCharNormArray(FEATURE_STRUCT const&, unsigned char*)+54)
    64362370  3f800000
    64362374  00000000
    64362378  5ee9d660
    6436237c  0000006e
    64362380  00000001
    64362384  0000006e
    64362388  df0027ad
    6436238c  00000000
    #00  64362390  64f3c868
    64362394  64fb8600
    64362398  5ee9ce90
    6436239c  5c43be18
    643623a0  64f3c868
    643623a4  64ed19c8
    643623a8  00000056
    643623ac  00000000
    643623b0  60bafa48
    643623b4  607aac83  /data/app-lib/br.com.nglauber.app.ocr-1/libtess.so (tesseract::Classify::CharNormTrainingSample(bool, int, tesseract::TrainingSample const&, GenericVector<tesseract::UnicharRating>*)+214)
    #01  643623b8  64ed19c8
    643623bc  607b2f51  /data/app-lib/br.com.nglauber.app.ocr-1/libtess.so (tesseract::Classify::ExtractFeatures(TBLOB const&, bool, GenericVector<INT_FEATURE_STRUCT>*, GenericVector<INT_FEATURE_STRUCT>*, INT_FX_RESULT_STRUCT*, GenericVector<int>*)+276)
    643623c0  643624ac
    643623c4  64f863c0
    643623c8  00000010
    643623cc  00000004
    643623d0  4018c03c
    643623d4  00000004
    643623d8  6337a750
    643623dc  ffffffff
    643623e0  643623e8
    643623e4  608e0c14  /data/app-lib/br.com.nglauber.app.ocr-1/libtess.so
    643623e8  ff40ff40
    643623ec  00c000c0
    643623f0  00000158
    643623f4  00000010
    memory near r0:
    5ee9d640 00000001 00000000 00000000 00000000
    5ee9d650 00000000 00000000 00000000 5eea89e0
    5ee9d660 00000000 00000000 00000000 00000000
    5ee9d670 00000000 5eea8c20 608919fe 60891a10
    5ee9d680 00000000 00000000 0000000
06-26 09:06:18.230    2347-2461/? D/CrashAnrDetector﹕ processName:br.com.nglauber.app.ocr
06-26 09:06:18.230    2347-2461/? D/CrashAnrDetector﹕ broadcastEvent : br.com.nglauber.app.ocr SYSTEM_TOMBSTONE

更多细节:
- 这是在正常的应用程序使用和我的测试期间(使用Espresso + Spoon)发生的 - 我正在使用运行Android 4.3的三星GT-I9300,但我认为其他设备也在发生 - 是的,我正在使用默认的construtor。 TessBaseAPI baseApi = new TessBaseAPI();
- 我在我的类中声明了baseApi作为字段,并在不同的Thread中调用了setImage和getUTF8Text几次(问题?)。当Activity被销毁时,我调用end()方法。
- 我正在使用此处提供的eng.traineddata:https://github.com/tesseract-ocr/tessdata

有什么想法吗?有没有一种好方法可以释放由tess-two分配的内存?

1 个答案:

答案 0 :(得分:0)

调用end()是释放tess-two分配的内存的正确方法,在单独的线程上运行OCR将有助于保持应用程序的响应。

这次崩溃显然是由于调用end()而另一个线程上的识别仍在进行中。