开发者

loading traineddata for tesseract-android-tools (android)

I am working on android app. What I need is directly path to traineddata file (to init tesserac开发者_StackOverflow社区t). Look like best option is to set the resource in raw.

I am getting resource ID this way (file name is : deu.traineddata):

int rID = resources.getIdentifier("deu", "raw", "my.code.package");

OK, 'rID' > 0, now getting Stream :

InputStream is = resources.openRawResource(rID);

ok, 'is' != null. But now getting problem ,by reading 'is' IOException has been throw, with no stack trace :

byte[] bytes = new byte[is.available()];
is.read(bytes);

I try also to read file from asset , but is the same problem by reading from InputStream. What i'am doing wrong, ist there any other way to get the resource path ? thanx andrej


If you look at the native code in tesseract-android-tools (under jni), you will see that the library will access a file. I am in the same boat at the moment. After some digging, my plan is to store the traineddata file as a resource along with the project, and write to the private file on load.

The pseudo code is something like this:

on load, check for private file, if it doesn't exist, load the traineddata from raw dir and write to the private file. initialize tesseract with the private file.

ref: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal http://developer.android.com/guide/topics/resources/providing-resources.html

Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜