Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dependencies {
- compile 'com.rmtheis:tess-two:6.0.2'
- }
- public String detectText(Bitmap bitmap) {
- TessBaseAPI tessBaseAPI = new TessBaseAPI();
- tessBaseAPI.setDebug(true);
- tessBaseAPI.init(DATA_PATH, "eng"); //Init the Tess with the trained data file, with english language
- //For example if we want to only detect numbers
- tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "1234567890");
- tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=-qwertyuiop[]}{POIU" +
- "YTREWQasdASDfghFGHjklJKLl;L:'"\|~`xcvXCVbnmBNM,./<>?");
- tessBaseAPI.setImage(bitmap);
- String text = tessBaseAPI.getUTF8Text();
- tessBaseAPI.end();
- return text;
- }
- DATA_PATH = Environment.getRootDirectory().getPath()+"/data/";
- DATA_PATH = Environment.getRootDirectory().getPath();
- DATA_PATH = Environment.getRootDirectory().getPath()+"/data/tessdata/";
- DATA_PATH = Environment.getRootDirectory().getPath()+"/tessdata/";
- DATA_PATH = Environment.getExternalStorageDirectory() + "/";
Add Comment
Please, Sign In to add comment