Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String detectText(Bitmap bitmap) {
- Log.d(TAG, "Initialization of TessBaseApi");
- TessDataManager.initTessTrainedData(context);
- TessBaseAPI tessBaseAPI = new TessBaseAPI();
- String path = TessDataManager.getTesseractFolder();
- Log.d(TAG, "Tess folder: " + path);
- tessBaseAPI.setDebug(true);
- tessBaseAPI.init(path, "eng");
- tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "1234567890-");
- tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=qwertyuiop[]}{POIU" +
- "YTREWQasdASDfghFGHjklJKLl;L:'"\|~`xcvXCVbnmBNM,./<>?");
- tessBaseAPI.setPageSegMode(TessBaseAPI.OEM_TESSERACT_CUBE_COMBINED);
- Log.d(TAG, "Ended initialization of TessEngine");
- Log.d(TAG, "Running inspection on bitmap");
- tessBaseAPI.setImage(bitmap);
- String inspection = tessBaseAPI.getUTF8Text();
- Log.d(TAG, "Got data: " + inspection);
- tessBaseAPI.end();
- System.gc();
- return inspection;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement