如何解决Tesseract!strcmp(locale,“ C”)错误?

时间:2019-03-10 20:13:34

标签: java sdk ocr tesseract webcam

我正在尝试使用Tesseract Java SDK创建OCR Java应用程序。 我正在使用Netbeans 9.0和JDK 11,Macbook Pro HighSierra。

我遇到此错误:

!strcmp(locale, "C"):Error:Assert failed:in file baseapi.cpp, line 209

A fatal error has been detected by the Java Runtime Environment:

SIGILL (0x4) at pc=0x000000012a003d96, pid=53684, tid=7171

JRE version: Java(TM) SE Runtime Environment (11.0.1+13) (build 11.0.1+13-LTS)
Java VM: Java HotSpot(TM) 64-Bit Server VM (11.0.1+13-LTS, mixed mode, tiered, compressed oops, g1 gc, bsd-amd64)
Problematic frame: C  [libtesseract.dylib+0x159d96]  ERRCODE::error(char const*, TessErrorLogCode, char const*, ...) const+0x178

No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

下面是我的代码。

import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamPanel;
import com.github.sarxos.webcam.WebcamResolution;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.swing.JFrame;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import com.asprise.ocr.Ocr;
import java.io.IOException;
import javax.imageio.ImageIO;

public class StratfordClasses {

    /**
     * @param args the command line arguments
     * @throws net.sourceforge.tess4j.TesseractException
     */
public static void main(String[] args) throws TesseractException, IOException {
    Webcam webcam = Webcam.getDefault();
    webcam.setViewSize(WebcamResolution.VGA.getSize());
    WebcamPanel panel = new WebcamPanel(webcam);
    panel.setFPSDisplayed(true);
    panel.setDisplayDebugInfo(true);
    panel.setImageSizeDisplayed(true);
    panel.setMirrored(true);
    BufferedImage image = webcam.getImage();
    File f = new File("Tests.png");
    ImageIO.write(image, "png", f);
    Tesseract tesseract = new Tesseract();
    try {
        String text = tesseract.doOCR(new File(f.getPath()));
        System.out.print(text);
    } catch (TesseractException e) {
        e.printStackTrace();
    }
    //ocr.stopEngine();
    JFrame window = new JFrame("Test webcam panel");
    window.add(panel);
    window.setResizable(true);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.pack();
    window.setVisible(true);
    }

}

我尝试了这个GitHub Solution,但还没有解决方法;

  1. 我在终端机上键入了此内容:导出LC_ALL = C ,但没有更改
  2. 我尝试安装版本3,但它给了我另一个错误错误:tesseract:“ cxx11”不是公认的标准

那请问如何使它工作呢?

1 个答案:

答案 0 :(得分:0)

您键入了export LC_ALL=C还是Export LC_ALL=C。第二个不正确。

也应该是cxx-11