Skip to content

Instantly share code, notes, and snippets.

@agnamc9
Created May 29, 2016 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agnamc9/feed3a160f78b925e880f00a4bd82638 to your computer and use it in GitHub Desktop.
Save agnamc9/feed3a160f78b925e880f00a4bd82638 to your computer and use it in GitHub Desktop.
Write and sava tess data from assets to device
String TESSBASE_PATH = Environment.getExternalStorageDirectory().toString() + "/tesseract/";
String[] files = {
"fra.cube.bigrams",
"fra.cube.fold",
"fra.cube.lm",
"fra.cube.nn",
"fra.cube.params",
"fra.cube.size",
"fra.cube.word-freq",
"fra.tesseract_cube.nn",
"fra.traineddata"
};
File dir = new File(TESSBASE_PATH + "tessdata");
String path = null;
for(int i = 0 ; i < files.length ; i++){
path = TESSBASE_PATH + "tessdata/" + files[i];
try {
AssetManager assetManager = activity.getAssets();
InputStream in = assetManager.open("tessdata/" + files[i]);
OutputStream out = new FileOutputStream(path);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (IOException e) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment