Guest User

Untitled

a guest
Jan 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. dependencies {
  2. compile 'com.rmtheis:tess-two:6.0.2'
  3. }
  4.  
  5. public String detectText(Bitmap bitmap) {
  6.  
  7. TessBaseAPI tessBaseAPI = new TessBaseAPI();
  8. tessBaseAPI.setDebug(true);
  9. tessBaseAPI.init(DATA_PATH, "eng"); //Init the Tess with the trained data file, with english language
  10.  
  11. //For example if we want to only detect numbers
  12. tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "1234567890");
  13. tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=-qwertyuiop[]}{POIU" +
  14. "YTREWQasdASDfghFGHjklJKLl;L:'"\|~`xcvXCVbnmBNM,./<>?");
  15.  
  16.  
  17. tessBaseAPI.setImage(bitmap);
  18.  
  19. String text = tessBaseAPI.getUTF8Text();
  20.  
  21. tessBaseAPI.end();
  22.  
  23. return text;
  24. }
  25.  
  26. DATA_PATH = Environment.getRootDirectory().getPath()+"/data/";
  27.  
  28. DATA_PATH = Environment.getRootDirectory().getPath();
  29.  
  30. DATA_PATH = Environment.getRootDirectory().getPath()+"/data/tessdata/";
  31.  
  32. DATA_PATH = Environment.getRootDirectory().getPath()+"/tessdata/";
  33.  
  34. DATA_PATH = Environment.getExternalStorageDirectory() + "/";
Add Comment
Please, Sign In to add comment