pethoalpar / AndroidTessTwoOCR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android TessTwo OCR example

Add dependency to app/build.gradle

dependencies {
...
compile 'com.rmtheis:tess-two:5.4.1'
...
}

Get text from bitmap

private String getText(Bitmap bitmap){
    try{
      tessBaseAPI = new TessBaseAPI();
    }catch (Exception e){
      Log.e(TAG, e.getMessage());
    }
    tessBaseAPI.init(DATA_PATH,"eng");
    tessBaseAPI.setImage(bitmap);
    String retStr = "No result";
    try{
      retStr = tessBaseAPI.getUTF8Text();
    }catch (Exception e){
      Log.e(TAG, e.getMessage());
    }
    tessBaseAPI.end();
    return retStr;
}

About


Languages

Language:Java 100.0%