Package cn.net.pap.common.tesseract.util
Class OCRUtils
java.lang.Object
cn.net.pap.common.tesseract.util.OCRUtils
OCR 工具类 - 基于 Tesseract Platform 5.5.1-1.5.12
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOCR 异常类static classOCR 结果对象 -
Method Summary
Modifier and TypeMethodDescriptionstatic voidprocessComponentLevelResults(org.bytedeco.tesseract.TessBaseAPI api, List<OCRUtils.OCRResult> results) 处理行级别结果static List<OCRUtils.OCRResult>recognizeWithCoordinates(String tessdataPath, String imagePath, String language) 执行 OCR 识别并返回带坐标的结果static List<OCRUtils.OCRResult>recognizeWithCoordinates(String tessdataPath, String imagePath, String language, int pageSegMode) 执行 OCR 识别并返回带坐标的结果(高级配置)static List<OCRUtils.OCRResult>recognizeWithWordCoordinates(String tessdataPath, String imagePath, String language) 获取字级别的 OCR 结果
-
Method Details
-
recognizeWithCoordinates
public static List<OCRUtils.OCRResult> recognizeWithCoordinates(String tessdataPath, String imagePath, String language) throws OCRUtils.OCRException 执行 OCR 识别并返回带坐标的结果- Parameters:
imagePath- 图像文件路径language- 语言代码 (如: "eng", "chi_sim", "eng+chi_sim")- Returns:
- 带坐标的 OCR 结果列表
- Throws:
OCRUtils.OCRException- 如果 OCR 处理失败
-
recognizeWithCoordinates
public static List<OCRUtils.OCRResult> recognizeWithCoordinates(String tessdataPath, String imagePath, String language, int pageSegMode) throws OCRUtils.OCRException 执行 OCR 识别并返回带坐标的结果(高级配置)- Parameters:
imagePath- 图像文件路径language- 语言代码pageSegMode- 页面分割模式- Returns:
- 带坐标的 OCR 结果列表
- Throws:
OCRUtils.OCRException- 如果 OCR 处理失败
-
processComponentLevelResults
public static void processComponentLevelResults(org.bytedeco.tesseract.TessBaseAPI api, List<OCRUtils.OCRResult> results) 处理行级别结果 -
recognizeWithWordCoordinates
public static List<OCRUtils.OCRResult> recognizeWithWordCoordinates(String tessdataPath, String imagePath, String language) throws OCRUtils.OCRException 获取字级别的 OCR 结果- Parameters:
tessdataPath- Tesseract tessdata 路径imagePath- 图像文件路径language- 语言代码 (如: "eng", "chi_sim", "eng+chi_sim")- Returns:
- 包含字级别 OCR 结果的列表
- Throws:
OCRUtils.OCRException- 如果 OCR 处理失败
-