Merge remote-tracking branch 'origin/dunhuan_jdk8' into dunhuang

# Conflicts:
#	pom.xml
This commit is contained in:
guoshengxiong 2025-10-16 16:55:13 +08:00
commit d4bd514d9a

View File

@ -14,12 +14,17 @@ import com.alibaba.fastjson.JSONObject;
import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.xmgl.call.api.OcrManufacturer; import com.zhgd.xmgl.call.api.OcrManufacturer;
import com.zhgd.xmgl.modules.ocr.entity.OcrConfig; import com.zhgd.xmgl.modules.ocr.entity.OcrConfig;
import com.zhgd.xmgl.util.FileUtils; import com.zhgd.xmgl.util.PathUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Base64; import java.util.Base64;
@Slf4j @Slf4j
@ -62,8 +67,11 @@ public class SmartJavaAIOcrCall 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");
FileUtils.getExportTemplateFile("/models/ocr/dict.txt"); String tmpdir = PathUtil.getBasePath();
recModelConfig.setRecModelPath(FileUtils.getExportTemplateFile("/models/ocr/PP-OCRv5_mobile_rec_infer.onnx").getAbsolutePath()); Files.copy(new ClassPathResource("/models/ocr/dict.txt").getInputStream(), Paths.get(tmpdir, "dict.txt"), StandardCopyOption.REPLACE_EXISTING);
Path recModelPath = Paths.get(tmpdir, "PP-OCRv5_mobile_rec_infer.onnx");
Files.copy(new ClassPathResource("/models/ocr/PP-OCRv5_mobile_rec_infer.onnx").getInputStream(), recModelPath, StandardCopyOption.REPLACE_EXISTING);
recModelConfig.setRecModelPath(recModelPath.toAbsolutePath().toString());
recModelConfig.setDevice(device); recModelConfig.setDevice(device);
recModelConfig.setTextDetModel(getDetectionModel()); recModelConfig.setTextDetModel(getDetectionModel());
return OcrModelFactory.getInstance().getRecModel(recModelConfig); return OcrModelFactory.getInstance().getRecModel(recModelConfig);
@ -80,7 +88,9 @@ public class SmartJavaAIOcrCall 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-OCRv5_mobile_det_infer.onnx").getAbsolutePath()); Path path = Paths.get(PathUtil.getBasePath(), "PP-OCRv5_mobile_det_infer.onnx");
Files.copy(new ClassPathResource("/models/ocr/PP-OCRv5_mobile_det_infer.onnx").getInputStream(), path, StandardCopyOption.REPLACE_EXISTING);
config.setDetModelPath(path.toAbsolutePath().toString());
config.setDevice(device); config.setDevice(device);
return OcrModelFactory.getInstance().getDetModel(config); return OcrModelFactory.getInstance().getDetModel(config);
} }