I am trying to use tesseract-ocr in my android app. When I am trying to init() I get IllegalArgumentException because in this folder there is no 'tessdata' dir! Here is my project structure. project structure
Here I used InputStream and cacheDir:
private String getDirPath() {
File f = new File(getCacheDir()+"/tessdata/");
if (!f.exists()) try {
InputStream is = getAssets().open("tessdata/eng.traineddata");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
FileOutputStream fos = new FileOutputStream(f);
fos.write(buffer);
fos.close();
} catch (Exception e) { Log.e("error", e.toString()); }
Log.i("wtf", f.getPath());
return getCacheDir();
}
To init the Tesseract I have to pass 2 arguments - path to dir which contains directory 'tessdata' and second one is traineddata. Any ideas?