[參考資料]
[需要權限]
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
[Gradle]
build.gradle (Module:app)
implementation 'com.rmtheis:tess-two:9.0.0'
public String runOcr( Bitmap bmp){
final TessBaseAPI ocrApi = new TessBaseAPI();
ocrApi.init( pathTessBase, "chi_tra");
ocrApi.setPageSegMode(TessBaseAPI.PageSegMode.PSM_AUTO);
ocrApi.setImage(bmp);
String resString = ocrApi.getUTF8Text();
ocrApi.clear();
ocrApi.end();
return resString;
}
[註]
1. 訓練資料檔 chi_tra.traineddata 必須放在 pathThessBase/tessdata 資料夾下.
2. PageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_LINE 只可辨識單行文字
1. 訓練資料檔 chi_tra.traineddata 必須放在 pathThessBase/tessdata 資料夾下.
2. PageSegmentationMode = TessBaseAPI.PageSegMode.PSM_SINGLE_LINE 只可辨識單行文字
PageSegmentationMode = TessBaseAPI.PageSegMode.PSM_AUTO 可辨識多行文字
No comments:
Post a Comment