Tesseract 解析图像并返回 null
我在超正方体方法中遇到问题。我使用下面的代码,我的应用程序直接停止。下面是我的 jni.cpp
文件。
struct native_data_t {
native_data_t() : image_obj(NULL), image_buffer(NULL) {}
tesseract::TessBaseAPI api;
jbyteArray image_obj;
jbyte* image_buffer;
int width, height, bpp;
char bBWFilter; // 0=disable, 1=enable
char bHorizontalDisplay;
};
native_data_t *nat = get_native_data(env, thiz);
if (nat->api.Init("/sdcard/","eng")) {
LOGE("could not initialize tesseract!");
res = JNI_FALSE;
}
你能帮我吗?这个 init 方法中的 datapath 是什么?提前致谢。
我的LogCat如下。
09-03 11:52:53.186: VERBOSE/MLOG: AssetsManager.java:(2263): isAssetsInstalled(): Assets are already correctly installed
09-03 11:52:53.186: VERBOSE/MLOG: OCR.java:(2263): GetLanguage(): eng
09-03 11:52:53.206: VERBOSE/MLOG: OCR.java:(2263): setLanguage to eng
09-03 11:52:53.206: VERBOSE/MLOG: OCR.java:(2263): noLangs=1
09-03 11:52:53.206: VERBOSE/OcrLib(native)(2263): ocr_open
09-03 11:52:53.206: INFO/OcrLib(native)(2263): lang eng
09-03 11:52:53.246: ERROR/OcrLib(native)(2263): IN BASE CPP
09-03 11:52:53.246: ERROR/OcrLib(native)(2263): IN 2nd if BASE CPP
09-03 11:52:53.326: INFO/ActivityThread(2253): Publishing provider com.google.android.maps.SearchHistoryProvider: com.google.googlenav.provider.SearchHistoryProvider
09-03 11:52:54.076: INFO/ActivityManager(123): Start proc com.android.voicedialer for broadcast com.android.voicedialer/.VoiceDialerReceiver: pid=2274 uid=10016 gids={3002}
09-03 11:52:54.206: INFO/ActivityManager(123): Stopping service: com.android.vending/.util.WorkService
09-03 11:52:54.336: INFO/ActivityManager(123): Process com.temp.unique.ocr (pid 2263) has died.
09-03 11:52:54.366: DEBUG/Zygote(122): Process 2263 exited cleanly (1)
09-03 11:52:54.756: INFO/dalvikvm(2274): Debugger thread not active, ignoring DDM send (t=0x41504e4d l=38)
09-03 11:52:54.766: DEBUG/vending(261): [43] LocalAssetCache.updateOnePackage(): No local info for com.temp.unique.ocr
我的包是com.temp.unique.ocr
。我的申请流程直接死掉了。
I have problem in tesseract method. i use below code and my application directly stop.Below is my jni.cpp
file.
struct native_data_t {
native_data_t() : image_obj(NULL), image_buffer(NULL) {}
tesseract::TessBaseAPI api;
jbyteArray image_obj;
jbyte* image_buffer;
int width, height, bpp;
char bBWFilter; // 0=disable, 1=enable
char bHorizontalDisplay;
};
native_data_t *nat = get_native_data(env, thiz);
if (nat->api.Init("/sdcard/","eng")) {
LOGE("could not initialize tesseract!");
res = JNI_FALSE;
}
can you help me?And what is datapath in this init method? thanks in advance.
my LogCat is as below.
09-03 11:52:53.186: VERBOSE/MLOG: AssetsManager.java:(2263): isAssetsInstalled(): Assets are already correctly installed
09-03 11:52:53.186: VERBOSE/MLOG: OCR.java:(2263): GetLanguage(): eng
09-03 11:52:53.206: VERBOSE/MLOG: OCR.java:(2263): setLanguage to eng
09-03 11:52:53.206: VERBOSE/MLOG: OCR.java:(2263): noLangs=1
09-03 11:52:53.206: VERBOSE/OcrLib(native)(2263): ocr_open
09-03 11:52:53.206: INFO/OcrLib(native)(2263): lang eng
09-03 11:52:53.246: ERROR/OcrLib(native)(2263): IN BASE CPP
09-03 11:52:53.246: ERROR/OcrLib(native)(2263): IN 2nd if BASE CPP
09-03 11:52:53.326: INFO/ActivityThread(2253): Publishing provider com.google.android.maps.SearchHistoryProvider: com.google.googlenav.provider.SearchHistoryProvider
09-03 11:52:54.076: INFO/ActivityManager(123): Start proc com.android.voicedialer for broadcast com.android.voicedialer/.VoiceDialerReceiver: pid=2274 uid=10016 gids={3002}
09-03 11:52:54.206: INFO/ActivityManager(123): Stopping service: com.android.vending/.util.WorkService
09-03 11:52:54.336: INFO/ActivityManager(123): Process com.temp.unique.ocr (pid 2263) has died.
09-03 11:52:54.366: DEBUG/Zygote(122): Process 2263 exited cleanly (1)
09-03 11:52:54.756: INFO/dalvikvm(2274): Debugger thread not active, ignoring DDM send (t=0x41504e4d l=38)
09-03 11:52:54.766: DEBUG/vending(261): [43] LocalAssetCache.updateOnePackage(): No local info for com.temp.unique.ocr
and my package is com.temp.unique.ocr
. My application process is directly died.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tesseract 2.04 已经有一个名为 Tesjeract 的 JNI 包装器。您可能想查看其源代码以了解他们是如何做到的。
datapath 是 tessdata 文件夹的路径,其中包含所有语言数据文件。
如果您感兴趣,还有一个名为 Tess4J 的基于 JNA 的解决方案。
There's already a JNI wrapper for Tesseract 2.04 named Tesjeract. You may want to look at its source code to see how they did it.
The datapath is the path to tessdata folder, which contains all the language data files.
There's also a JNA-based solution named Tess4J, if you're interested.