Class OCRUtils

java.lang.Object
cn.net.pap.common.tesseract.util.OCRUtils

public class OCRUtils extends Object
OCR 工具类 - 基于 Tesseract Platform 5.5.1-1.5.12
  • 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 处理失败