【发布时间】: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变量的内容。