Reputation: 3127
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.
Upvotes: 1
Views: 899
Reputation: 8345
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.
Upvotes: 1