Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public String detectText(Bitmap bitmap) {
  2. Log.d(TAG, "Initialization of TessBaseApi");
  3. TessDataManager.initTessTrainedData(context);
  4. TessBaseAPI tessBaseAPI = new TessBaseAPI();
  5. String path = TessDataManager.getTesseractFolder();
  6. Log.d(TAG, "Tess folder: " + path);
  7. tessBaseAPI.setDebug(true);
  8. tessBaseAPI.init(path, "eng");
  9. tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "1234567890-");
  10. tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=qwertyuiop[]}{POIU" +
  11. "YTREWQasdASDfghFGHjklJKLl;L:'"\|~`xcvXCVbnmBNM,./<>?");
  12. tessBaseAPI.setPageSegMode(TessBaseAPI.OEM_TESSERACT_CUBE_COMBINED);
  13. Log.d(TAG, "Ended initialization of TessEngine");
  14. Log.d(TAG, "Running inspection on bitmap");
  15. tessBaseAPI.setImage(bitmap);
  16. String inspection = tessBaseAPI.getUTF8Text();
  17. Log.d(TAG, "Got data: " + inspection);
  18. tessBaseAPI.end();
  19. System.gc();
  20. return inspection;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement