2012-09-23 77 views
1

我從here下載了Tesseract OCR for Android,我試圖用NDK將它構建爲我自己的應用程序的庫項目。我收到了一些有關如何執行此操作的有用反饋here。首先,我做這在命令行([路徑]是的路徑苔絲個項目的簡寫):UnsatisfiedLinkError - Tesseract for Android

> cd [path]\tess-two 

> C:\android-ndk-r8b-windows\android-ndk-r8b\ndk-build -j8 

"Compile thumb : lept <= adaptmap.c 

[...] 

"Compile++ thumb : lept <= writefile.cpp 

Prebuilt  : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/ 

"Compile++ thumb : tess <= applybox.cpp 

[...] 

"Compile++ thumb : tess <= tessbaseapi.cpp 

"Compile thumb : lept <= adaptmap.c 

[...] 

"Compile++ thumb : lept <= pixa.cpp 

Prebuilt  : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/ 

"Compile++ thumb : lept <= jni.cpp 

[...] 

"Compile++ thumb : tess <= tessbaseapi.cpp 

"Compile x86 : lept <= affine.c 

[...] 

"Compile++ x86 : lept <= readfile.cpp 

Prebuilt  : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/4.6/libs/x86/ 

"Compile++ x86 : tess <= baseapi.cpp 

[...] 

"Compile++ x86 : tess <= wordclass.cpp 

SharedLibrary : liblept.so 

SharedLibrary : liblept.so 

"Compile++ x86 : tess <= tessbaseapi.cpp 

SharedLibrary : liblept.so 

"Compile++ x86 : tess <= wordrec.cpp 

SharedLibrary : libtess.so 

Install  : liblept.so => libs/x86/liblept.so 

Install  : liblept.so => libs/armeabi/liblept.so 

SharedLibrary : libtess.so 

Install  : liblept.so => libs/armeabi-v7a/liblept.so 

SharedLibrary : libtess.so 

Install  : libtess.so => libs/armeabi/libtess.so 

Install  : libtess.so => libs/armeabi-v7a/libtess.so 

Install  : libtess.so => libs/x86/libtess.so 


> C:\Users\User\android-sdk\tools\android.bat update project --path . 

Failed to convert path to a short DOS path: C:\Windows\system32\java.exe 
'javaw_exe' is not recognized as an internal or external command, 
operable program or batch file. 
Updated local.properties 

Updated file [path]\tess-two\proguard-project.txt 

It seems that there are sub-projects. If you want to update them 

please use the --subprojects parameter. 

> set JAVA_HOME=C:\Java\JDK 
> Buildfile: [path]\tess-two\build.xml 

-set-mode-check: 

-set-release-mode: 

-release-obfuscation-check: 
    [echo] proguard.config is ${proguard.config} 

-check-env: 
[checkenv] Android SDK Tools Revision 20.0.3 
[checkenv] Installed at C:\Users\User\android-sdks 

-setup: 
    [echo] Project Name: tess-two 
    [gettype] Project Type: Android Library 

-build-setup: 
    [echo] Resolving Build Target for tess-two... 
[gettarget] Project Target: Google APIs 
[gettarget] Vendor:   Google Inc. 
[gettarget] Platform Version: 4.1 
[gettarget] API level:  16 
    [echo] ---------- 
    [echo] Creating output directories if needed... 
    [echo] ---------- 
    [echo] Resolving Dependencies for tess-two... 
[dependency] Library dependencies: 
[dependency] No Libraries 
[dependency] 
[dependency] ------------------ 
[dependency] API<=15: Adding annotations.jar to the classpath. 
    [echo] ---------- 
    [echo] Building Libraries with 'release'... 
    [subant] No sub-builds to iterate on 

-pre-build: 

-code-gen: 
[mergemanifest] Found Deleted Target File 
[mergemanifest] Merging AndroidManifest files into one. 
[mergemanifest] Manifest merger disabled. Using project manifest only. 
    [echo] Handling aidl files... 
    [aidl] No AIDL files to compile. 
    [echo] ---------- 
    [echo] Handling RenderScript files... 
[renderscript] No RenderScript files to compile. 
    [echo] ---------- 
    [echo] Handling Resources... 
    [aapt] Found new input file 
    [aapt] Generating resource IDs... 
    [echo] ---------- 
    [echo] Handling BuildConfig class... 
[buildconfig] No need to generate new BuildConfig. 

-pre-compile: 

-compile: 
    [echo] Creating library output jar file... 

-post-compile: 

-obfuscate: 

-dex: 
    [echo] Library project: do not convert bytecode... 

-crunch: 
    [crunch] Crunching PNG Files in source dir: [path]\tess-two\res 
    [crunch] To destination dir: [path]\tess-two\bin\res 
    [crunch] Crunched 0 PNG files to update cache 

-package-resources: 
    [echo] Library project: do not package resources... 

-package: 
    [echo] Library project: do not package apk... 

-post-package: 

-release-prompt-for-password: 

-release-nosign: 
    [echo] 
[propertyfile] Updating property file: [path]\tess-two\bin\build.prop 
[propertyfile] Updating property file: [path]\tess-two\bin\build.prop 
[propertyfile] Updating property file: [path]\tess-two\bin\build.prop 
[propertyfile] Updating property file: [path]\tess-two\bin\build.prop 

-release-sign: 

-post-build: 

release: 

BUILD SUCCESSFUL 
Total time: 1 second 

然後,我這樣做: 文件 - >導入 - > Android的 - >現有代碼進入工作區 - >瀏覽 - >選擇當前工作區目錄 - >確保在出現的列表中選擇了tess-two - >完成。

然後我右鍵單擊我自己的應用程序,進入屬性 - > Android選項卡 - >添加...(在庫部分下) - >選擇tess-two - >單擊確定 - >檢查「庫」 - >好的。

然而,這一切後,我還是運行我的應用程序時,你得到follwing錯誤:

09-23 13:02:42.532: E/AndroidRuntime(675): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load lept: findLibrary returned null 
09-23 13:02:42.532: E/AndroidRuntime(675): at java.lang.Runtime.loadLibrary(Runtime.java:365) 
09-23 13:02:42.532: E/AndroidRuntime(675): at java.lang.System.loadLibrary(System.java:535) 
09-23 13:02:42.532: E/AndroidRuntime(675): at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:47) 

爲自己的應用程序的project.properties是:

target=android-16 
android.library.reference.1=..\\OpenCV\\sdk\\java 
android.library.reference.2=../Tesseract/tess-two 
android.library=true 

這是怎麼回事?

+0

如果任何人都可以給我一些關於我應該包含哪些其他信息以幫助他人回答問題的反饋,我真的很感激。 –

+0

也包括你的project.properties。 – rmtheis

+1

請勿爲自己的項目檢查「is Library」。苔絲二應該是圖書館項目。 – rmtheis

回答

1

我明白了,問題在於我沒有正確地初始化我的代碼中的API。正確的語法是:

tesseract.init("/mnt/sdcard/", "eng"); 

假設你已經有了下MNT/SD卡的文件夾「tessdata」。現在它完美加載!非常感謝您的幫助!

+0

嗨plz幫我在哪裏我要寫這行可以üPLZ提及在哪個類 –

0

我,而不是2調用LoadLibrary我做了所有4作爲

System.loadLibrary("jpgt"); System.loadLibrary("pngt"); System.loadLibrary("lept"); System.loadLibrary("tess"); 和它的工作。