我正在尝试使用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,但还没有解决方法;
那请问如何使它工作呢?
答案 0 :(得分:0)
您键入了export LC_ALL=C
还是Export LC_ALL=C
。第二个不正确。
也应该是cxx-11