【问题标题】:I have used tess4j to extract text from image but not getting correct result我使用 tess4j 从图像中提取文本但没有得到正确的结果
【发布时间】:2018-12-27 12:04:39
【问题描述】:

我使用了 tess4j 但没有得到正确的结果。 下面是我的代码。

 public static String crackImage(String filePath) {


  BufferedImage img = null;
  try {
      img = ImageIO.read(new File(filePath));
  } catch (IOException e) {
  }
    ITesseract instance = new Tesseract();
    instance.setLanguage("eng");
  //  instance.setPageSegMode((3));
 img=  ImageHelper.convertImageToGrayscale(img);
    instance.setDatapath("C:\\tessdata");

    try {
        String result = instance.doOCR(img);
        return result;
    } catch (TesseractException e) {
        System.err.println(e.getMessage());
        return "Error while reading image";
    }
}

我附上了示例图片。

我的输出是:

arm m 方式:a;男人

mFL/Vemmnh 1951 mm 8221 11m 3521|\|\|II\IIIIIIHIIIIIIHIIIH

人渣——WWW

%'

请建议我怎样才能得到正确的结果

【问题讨论】:

    标签: java ocr tess4j


    【解决方案1】:

    这是最佳实践,

    在运行该 tess4j 命令之前,您需要使用 (OpenCV) 进行图像处理。 https://github.com/tesseract-ocr/tesseract/wiki/ImproveQuality

    或者您可以选择 Google Ml KIT

    https://firebase.google.com/docs/ml-kit/recognize-text

    【讨论】:

      猜你喜欢
      • 2021-10-08
      • 2015-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多