我尝试使用 tesseract tess-two 从 android 中的图像中读取问题和答案。目前,我得到一个字符串,其中包含图像上的每个单词。我的问题是我无法拆分答案是否可以使用 TessBaseAPI 拆分答案?java/android 中的解决方案也可以;)
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, "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"abcdefghijklnmopqrstuvwxyzäüößÄÖÜ!?@#$%^&*+=-;()/");
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;
}