【问题标题】:How to perform OCR on an image containing euro symbol with Tess4J?如何使用 Tess4J 对包含欧元符号的图像执行 OCR?
【发布时间】:2016-02-27 14:25:07
【问题描述】:

我有以下图像想要 OCR:

我为此使用Tess4J 并关注these instructions

这就是我正在尝试的:

import java.io.File;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.TesseractException;


public class Main {

    public static void main(String[] args) {

//        Perform OCR
//        ===========
        File imageFile = new File("./CroppedSubtotal.png");
        ITesseract instance = new Tesseract();  // JNA Interface Mapping

        try {
            String result = instance.doOCR(imageFile);
            System.out.println("====== Result: " + result);
        } catch (TesseractException e) {
            System.err.println(e.getMessage());
        }
    }
}

当我在 IntelliJ 中运行它时,控制台会返回以下内容:

/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk ...
====== Result: 

Process finished with exit code 0

我可以尝试什么来解决这个问题?

更新:

当我对下面的图像进行 OCR 时,它确实有效

欧元符号一定是原因。我尝试将其添加到白名单,但没有成功

instance.setTessVariable("tessedit_char_whitelist", "€0123456789,.");

【问题讨论】:

  • 当你从命令行运行它时?另外:在打印结果的行上添加断点并检查result 变量的内容。

标签: java ocr tesseract tess4j


【解决方案1】:

Tesseract 使用英文数据包可以很好地识别欧元符号。您的控制台可能无法显示它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-13
    相关资源
    最近更新 更多