2016-10-28 25 views
0

Mac OS X。JDK7とJDK8の両方を試しました。TesseractとJavaラッパーライブラリTess4Jを使用して簡単なプログラムを実行すると、Tesseract/Tess4JがMac OS Xでクラッシュする問題フレーム:C [libtesseract.dylib + 0xcf72] tesseract :: TessResultRenderer ::〜TessResultRenderer()+ 0x10

コードはイメージ上でOCRを実行し、その中からPDFを作成します。コードは機能し、それが何をすべきかを行います(pdfはうまく作成されます)。しかし、結局私はMacでクラッシュレポートを受け取ります。

private static void testTesseract() throws Exception { 
    File imageFile = new File("/Users/mln/Desktop/urkunde.jpg"); 
    ITesseract instance = new Tesseract(); // JNA Interface Mapping 

    // http://tess4j.sourceforge.net/tutorial/ 

    instance.setDatapath("/Users/mln/Desktop/tessdata"); 
    instance.setLanguage("deu"); 

    try { 
     String result = instance.doOCR(imageFile); 
     System.out.println(result); 
    } catch (TesseractException e) { 
     System.err.println(e.getMessage()); 
    } 

    List<ITesseract.RenderedFormat> list = new ArrayList<ITesseract.RenderedFormat>(); 
    list.add(ITesseract.RenderedFormat.PDF); 
    File pdfFile = new File("/Users/mln/Desktop/urkunde.jpg"); 
    instance.createDocuments(pdfFile.getAbsolutePath(), "/Users/mln/Desktop/urkunde", list); 

} 

クラッシュの原因となる行は、この最後のものである:

instance.createDocuments(pdfFile.getAbsolutePath(), "/Users/mln/Desktop/urkunde", list); 

コンソール出力:

Warning in pixReadMemJpeg: work-around: writing to a temp file 
# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# SIGSEGV (0xb) at pc=0x00000001295c9f72, pid=6336, tid=5891 
# 
# JRE version: Java(TM) SE Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13) 
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.31-b07 mixed mode bsd-amd64 compressed oops) 
# Problematic frame: 
# C [libtesseract.dylib+0xcf72] tesseract::TessResultRenderer::~TessResultRenderer()+0x10 
# 
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again 
# 
# An error report file with more information is saved as: 
# /Users/mln/Projects/jackrabbit-client/hs_err_pid6336.log 
# 
# If you would like to submit a bug report, please visit: 
# http://bugreport.java.com/bugreport/crash.jsp 
# The crash happened outside the Java Virtual Machine in native code. 
# See problematic frame for where to report the bug. 
# 

Process finished with exit code 134 (interrupted by signal 6: SIGABRT) 

とクラッシュレポート:

Process:    java [6336] 
Path:     /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/bin/java 
Identifier:   net.java.openjdk.cmd 
Version:    1.0 (1.0) 
Code Type:    X86-64 (Native) 
Parent Process:  idea [81650] 
Responsible:   java [6336] 
User ID:    501 

Date/Time:    2016-10-28 11:09:35.377 +0200 
OS Version:   Mac OS X 10.11.6 (15G1004) 
Report Version:  11 
Anonymous UUID:  6CF2EEC0-C9B5-315F-EB2E-5AEBDF0094FD 

Sleep/Wake UUID:  F9F2D823-9374-4EC4-B8FD-9342826E1A37 

Time Awake Since Boot: 600000 seconds 
Time Since Wake:  10000 seconds 

System Integrity Protection: enabled 

Crashed Thread:  4 

Exception Type:  EXC_BAD_ACCESS (SIGABRT) 
Exception Codes:  EXC_I386_GPFLT 
Exception Note:  EXC_CORPSE_NOTIFY 

Application Specific Information: 
abort() called 

コンプリート出力ペーストビンに:http://pastebin.com/v9gPd4hk

+0

エラーはLeptonicaに由来しているようです。あなたの 'libjpeg'ライブラリで何かができました。 – nguyenq

+0

@nguyenq MacOS Xのもっと一般的な問題と思われます。私はソースからプロジェクトを構築しようとしますが、これはすでにユニットテストでエラー['junit] 10:04:57.140 [main] ERROR net.sourceforge .tess4j.Tesseract1 - ライブラリ 'gs'を読み込めません:ネイティブライブラリ(darwin/libgs.dylib)がリソースパスに見つかりません。ログ:http://pastebin.com/Ba4wUYYu、これも既知の問題であるようです:http://stackoverflow.com/questions/21394537/tess4j-unsatisfied-link-error-on-mac-os-x –

+0

'gs'の問題では、GhostScriptをインストールする必要があります。 Tess4JはPDFファイルを読むことに依存しています。 – nguyenq

答えて

1

私は自分でテストしていませんが、createDocumentsはinit()dispose()を呼び出すので、doOCR()を呼び出します。これらのメソッドをオーバーライドして1回だけ呼び出すことができます。暗闇の中の一種のショットですが、それは妥当と思われます。

+0

ありがとう、私は明日試してみます。残念ながら私はTesseractクラスを拡張することはできません。なぜなら、createRenderersメソッドとcreateDocumentsメソッドは保護されているのではなく、privateであるからです。だから私はすべてを構築する必要があります。 –

+0

幸いにも、一目見てもそれほど悪くはありません。コピー&ペーストのビット。がんばろう。 – Araymer

+0

ソースからプロジェクトをビルドしようとしましたが、エラー['junit] 10:04:57.140 [main] ERROR net.sourceforge.tess4j.Tesseract1 - ライブラリ 'gs'をロードできませんでした。ネイティブライブラリ(darwin/libgs.dylib)がリソースパス 'に見つかりません。ログ:http://pastebin.com/Ba4wUYYu、これも既知の問題であるようです:http://stackoverflow.com/questions/21394537/tess4j-unsatisfied-link-error-on-mac-os-x –

関連する問題