【实例简介】
【实例截图】
【核心代码】
// 通用文字识别参数设置
GeneralBasicParams param = new GeneralBasicParams();
param.setDetectDirection(true);
param.setImageFile(new File(filePath));
// 调用通用文字识别服务
OCR.getInstance().recognizeGeneralBasic(param, new OnResultListener() {
@Override
public void onResult(GeneralResult result) {
// 调用成功,返回GeneralResult对象
for (WordSimple wordSimple : result.getWordList()) {
// wordSimple不包含位置信息
wordSimple word = wordSimple;
sb.append(word.getWords());
sb.append("\n");
}
// json格式返回字符串
listener.onResult(result.getJsonRes());
}
@Override
public void onError(OCRError error) {
// 调用失败,返回OCRError对象
}
});