Created
May 29, 2016 08:14
-
-
Save agnamc9/feed3a160f78b925e880f00a4bd82638 to your computer and use it in GitHub Desktop.
Write and sava tess data from assets to device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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