i'm trying copy files tesseract use , no matter how try keeps giving me filenot found exceptions. don't understand why because have them in assets folder. tried 1 way copying specific tessdata folder wasn't working tried putting them under general assets folder , copying each file in there new directory created on card called tessdata.
here's image of files in folder, method copying , log errors post:
and here's code:
private void copyassets() { assetmanager assetmanager = getassets(); string[] files = null; try { files = assetmanager.list(""); } catch (ioexception e) { android.util.log.e(tag, "failed asset file list.", e); } for(string filename : files) { inputstream in = null; outputstream out = null; try { in = assetmanager.open(filename); out = new fileoutputstream(tesspath+ "/" + filename); copyfile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } catch(ioexception e) { android.util.log.e("tag", "failed copy asset file: " + filename, e); } } }
-i tried using method example copied them tessdata folder within assets-
if (!(new file(tesspath + file.separator + lang + ".traineddata")).exists()) { copyassets(); /* try { assetmanager assetmanager = getassets(); //open asset manager , open traineddata path inputstream in = assetmanager.open("tessdata/eng.traineddata"); android.util.log.e(tag, "opened if no error before this"); outputstream out = new fileoutputstream(tesspath + "/eng.traineddata"); android.util.log.e(tag, "writing to" + tesspath); byte[] buf = new byte[8024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } catch (ioexception e) { android.util.log.e(tag, "was unable copy " + lang + " traineddata " + e.tostring()); android.util.log.e(tag, "im printing stack traces"); e.printstacktrace(); } */ } else { processimage(storage_path + file.separator + "savedandroid.jpg"); }
have checked sdcard write perssion in manifest.xml ? need in androidmanifest.xml
<uses-permission android:name="android.permission.write_external_storage" />
Comments
Post a Comment