3
我剛剛從http://tess4j.sourceforge.net/下載了Tess4J,並將它導入到netbeans中。代碼正在運行,但是當我輸入圖像的URL並嘗試轉換它時,我得到一個錯誤。沒有輸入源設置錯誤異常Tess4J
我的代碼:
public static void main(String[] args) {
File imageFile = new File("http://www.example.com/example-image.png");
Tesseract instance = Tesseract.getInstance(); //
try {
String result = instance.doOCR(imageFile);
System.out.println(result);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
}
輸出錯誤:
02:51:36.251 [main] ERROR net.sourceforge.tess4j.Tesseract - No input source set!
java.lang.IllegalStateException: No input source set!
java.lang.IllegalStateException: No input source set!
at com.sun.imageio.plugins.png.PNGImageReader.getNumImages(PNGImageReader.java:1347)
at net.sourceforge.tess4j.util.ImageIOHelper.getIIOImageList(ImageIOHelper.java:337)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
at Testing.main(Testing.java:23)
其他人遇到這樣的事情之前?我發現3個更多類似的主題,但他們並沒有幫助我..