SmartJavaAIOrc的bug修改
This commit is contained in:
parent
098bb63b31
commit
73a2fc37b2
@ -85,7 +85,7 @@ public class BaiDuOrcCall implements OcrManufacturer {
|
|||||||
log.info("百度AI 手写文字识别,result:{}", result);
|
log.info("百度AI 手写文字识别,result:{}", result);
|
||||||
OcrResult ocrResult = JSONObject.parseObject(result, OcrResult.class);
|
OcrResult ocrResult = JSONObject.parseObject(result, OcrResult.class);
|
||||||
if (CollUtil.isNotEmpty(ocrResult.getWords_result())) {
|
if (CollUtil.isNotEmpty(ocrResult.getWords_result())) {
|
||||||
return ocrResult.getWords_result().stream().map(OcrResult.WordsResult::getWords).collect(Collectors.joining());
|
return ocrResult.getWords_result().stream().map(wordsResult -> wordsResult.getWords()+"\n").collect(Collectors.joining());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class SmartJavaAIOrcCall implements OcrManufacturer {
|
|||||||
public String ocrHandwriting(String base64Img) {
|
public String ocrHandwriting(String base64Img) {
|
||||||
try {
|
try {
|
||||||
OcrCommonRecModel recModel = getRecModel();
|
OcrCommonRecModel recModel = getRecModel();
|
||||||
OcrInfo ocrInfo = recModel.recognize(Base64.getDecoder().decode(base64Img), new OcrRecOptions());
|
OcrInfo ocrInfo = recModel.recognize(Base64.getDecoder().decode(base64Img.contains(",") ? base64Img.substring(base64Img.indexOf(",") + 1) : base64Img), new OcrRecOptions());
|
||||||
log.info("OCR识别结果:{}", JSONObject.toJSONString(ocrInfo));
|
log.info("OCR识别结果:{}", JSONObject.toJSONString(ocrInfo));
|
||||||
return ocrInfo != null ? ocrInfo.getFullText() : null;
|
return ocrInfo != null ? ocrInfo.getFullText() : null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -63,7 +63,8 @@ public class SmartJavaAIOrcCall implements OcrManufacturer {
|
|||||||
recModelConfig.setRecModelEnum(CommonRecModelEnum.PP_OCR_V5_MOBILE_REC_MODEL);
|
recModelConfig.setRecModelEnum(CommonRecModelEnum.PP_OCR_V5_MOBILE_REC_MODEL);
|
||||||
//指定识别模型位置,需要更改为自己的模型路径(下载地址请查看文档)
|
//指定识别模型位置,需要更改为自己的模型路径(下载地址请查看文档)
|
||||||
// recModelConfig.setRecModelPath("/Users/xxx/Documents/develop/model/ocr/PP-OCRv5_mobile_rec_infer/PP-OCRv5_mobile_rec_infer.onnx");
|
// recModelConfig.setRecModelPath("/Users/xxx/Documents/develop/model/ocr/PP-OCRv5_mobile_rec_infer/PP-OCRv5_mobile_rec_infer.onnx");
|
||||||
recModelConfig.setRecModelPath(Fileutils.getExportTemplateFile("models/ocr/PP-OCRv5_mobile_rec_infer.onnx").getAbsolutePath());
|
Fileutils.getExportTemplateFile("/models/ocr/dict.txt");
|
||||||
|
recModelConfig.setRecModelPath(Fileutils.getExportTemplateFile("/models/ocr/PP-OCRv5_mobile_rec_infer.onnx").getAbsolutePath());
|
||||||
recModelConfig.setDevice(device);
|
recModelConfig.setDevice(device);
|
||||||
recModelConfig.setTextDetModel(getDetectionModel());
|
recModelConfig.setTextDetModel(getDetectionModel());
|
||||||
return OcrModelFactory.getInstance().getRecModel(recModelConfig);
|
return OcrModelFactory.getInstance().getRecModel(recModelConfig);
|
||||||
@ -80,7 +81,7 @@ public class SmartJavaAIOrcCall implements OcrManufacturer {
|
|||||||
config.setModelEnum(CommonDetModelEnum.PP_OCR_V5_MOBILE_DET_MODEL);
|
config.setModelEnum(CommonDetModelEnum.PP_OCR_V5_MOBILE_DET_MODEL);
|
||||||
//指定模型位置,需要更改为自己的模型路径(下载地址请查看文档)
|
//指定模型位置,需要更改为自己的模型路径(下载地址请查看文档)
|
||||||
// config.setDetModelPath("/Users/xxx/Documents/develop/model/ocr/PP-OCRv5_mobile_det_infer/PP-OCRv5_mobile_det_infer.onnx");
|
// config.setDetModelPath("/Users/xxx/Documents/develop/model/ocr/PP-OCRv5_mobile_det_infer/PP-OCRv5_mobile_det_infer.onnx");
|
||||||
config.setDetModelPath(Fileutils.getExportTemplateFile("models/ocr/PP-PP-OCRv5_mobile_det_infer.onnx").getAbsolutePath());
|
config.setDetModelPath(Fileutils.getExportTemplateFile("/models/ocr/PP-OCRv5_mobile_det_infer.onnx").getAbsolutePath());
|
||||||
config.setDevice(device);
|
config.setDevice(device);
|
||||||
return OcrModelFactory.getInstance().getDetModel(config);
|
return OcrModelFactory.getInstance().getDetModel(config);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user