Android版的tesseract应用程序崩溃的OCR功能 [英] Android Tesseract App crashes on OCR Function
问题描述
我想实现的tesseract到我的Android项目,而是试图完成OCR当我得到一个崩溃。
下面是如何我设立的tesseract:
TessBaseAPI baseApi =新TessBaseAPI();
baseApi.setDebug(真);
baseApi.init(的ImagePath,工程);
baseApi.setImage(位图);
串recognizedText = baseApi.getUTF8Text();
baseApi.end();
这是我如何建立图像信息传递到TesseractAPI:
目标=新的文件(Environment.getExternalStorageDirectory()名+png格式); 的ImagePath = destination.getAbsolutePath(); 字符串名称= dateToString(新的Date(),YYYY-MM-DD-HH-MM-SS);
下面是logcat的:
10734-10734 / www.rshdev.com.ocr E / AndroidRuntime:致命异常:主要
工艺:www.rshdev.com.ocr,PID:10734
java.lang.UnsatisfiedLinkError中:dalvik.system.PathClassLoader [DexPathList [zip文件/data/app/www.rshdev.com.ocr-1/base.apk\"],nativeLibraryDirectories=[/vendor/lib,/系统/ LIB]]]找不到libpngt.so
在java.lang.Runtime.loadLibrary(Runtime.java:366)
在java.lang.System.loadLibrary(System.java:988)
在com.google code.tesseract.android.TessBaseAPI< clinit>(TessBaseAPI.java:43)
在www.rshdev.com.ocr.MainActivity.ocr(MainActivity.java:140)
在www.rshdev.com.ocr.MainActivity.onActivityResult(MainActivity.java:86)
在android.app.Activity.dispatchActivityResult(Activity.java:6192)
在android.app.ActivityThread.deliverResults(ActivityThread.java:3570)
在android.app.ActivityThread.handleSendResult(ActivityThread.java:3617)
在android.app.ActivityThread.access $ 1300(ActivityThread.java:151)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1352)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:135)
在android.app.ActivityThread.main(ActivityThread.java:5254)
在java.lang.reflect.Method.invoke(本机方法)
在java.lang.reflect.Method.invoke(Method.java:372)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:903)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
您的tesseract不OCR功能崩溃,崩溃试图加载库:
java.lang.UnsatisfiedLinkError中:...找不到libpngt.so
...
在com.google code.tesseract.android.TessBaseAPI< clinit>(TessBaseAPI.java:43)
不过,我有源行43读取:
的System.loadLibrary(苔丝);
因此它会尝试加载的 libtess.so 的,但是,报告失败的 libpngt.so 的
或者:
1)TessBaseAPI.java的源$ C $ c是不同的,它包含了的System.loadLibrary(pngt);
和库丢失。确保.apk文件包含它。日食曾经有一个不好的特性:如果你的$ C $,c取决于库中,将配置依赖在编译在一个地方,交付在另一个地方。和IIRC。所以依赖于一个第三名指定。
2)libtess.so与动态链接编译(尽量使用静态链接即可)
3)你想在模拟器(尝试一个真正的设备上的话)运行它。
这是什么都可以从您提供的信息说。
I am trying to implement Tesseract into my android project but am getting a crash when trying to complete the OCR.
Here is how I'm setting up Tesseract:
TessBaseAPI baseApi = new TessBaseAPI();
baseApi.setDebug(true);
baseApi.init(imagePath, "eng");
baseApi.setImage(bitmap);
String recognizedText = baseApi.getUTF8Text();
baseApi.end();
This is how I'm setting up the image information to pass into the TesseractAPI:
destination = new File(Environment.getExternalStorageDirectory(), name + ".png");
imagePath = destination.getAbsolutePath();
String name = dateToString(new Date(),"yyyy-MM-dd-hh-mm-ss");
Here is the Logcat:
10734-10734/www.rshdev.com.ocr E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: www.rshdev.com.ocr, PID: 10734
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/www.rshdev.com.ocr-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libpngt.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:988)
at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:43)
at www.rshdev.com.ocr.MainActivity.ocr(MainActivity.java:140)
at www.rshdev.com.ocr.MainActivity.onActivityResult(MainActivity.java:86)
at android.app.Activity.dispatchActivityResult(Activity.java:6192)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3570)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3617)
at android.app.ActivityThread.access$1300(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1352)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Your tesseract does not crash in the OCR function, it crashes trying to load a library:
java.lang.UnsatisfiedLinkError: ... couldn't find "libpngt.so"
...
at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:43)
But line 43 in the source that I have reads:
System.loadLibrary("tess");
therefore it tries to load libtess.so but reports a failure on libpngt.so.
Either:
1) your source code of TessBaseAPI.java is different, it contains System.loadLibrary("pngt");
and that library is missing. Make sure the .apk contains it. Eclipse used to have a misfeature: if your code depends on a library, you configure that dependency for compilation in one place and for delivery in another place. And IIRC .so dependency was specified in a 3rd place.
2) libtess.so is compiled with dynamic linking (try to use static linking then)
3) you are trying to run it in the emulator (try on a real device then).
This is all what can be said from the information you provided.
这篇关于Android版的tesseract应用程序崩溃的OCR功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!