java.lang.RuntimeException: Unsupported image format. May need to install JAI Image I/O package.
https://github.com/jai-imageio/jai-imageio-core
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:215) ~[tess4j-4.5.5.jar:4.5.5]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:195) ~[tess4j-4.5.5.jar:4.5.5]
File ocrFile = new File("ocr.png ");
//使用OCR提取图片文字
Tesseract tesseract = new Tesseract();
//设置 Tesseract 数据文件的路径,如果不是默认路径的话
//tesseract.setDatapath("path_to_your_tessdata_folder");
try {
String result = tesseract.doOCR(ocrFile);
System.out.println(result);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
其他
java.lang.RuntimeException: Unsupported image format. May need to install JAI Image I/O package.
https://github.com/jai-imageio/jai-imageio-core
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:215) ~[tess4j-4.5.5.jar:4.5.5]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:195) ~[tess4j-4.5.5.jar:4.5.5]
Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: no opencv_java470 in java.library.path: D:\Java\jdk-17.0.8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\Microsoft SQL Server\160\Tools\Binn\;C:\Program Files\Microsoft SQL Server\160\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\160\DTS\Binn\;C:\Program Files\Docker\Docker\resources\bin;D:\Java\jdk-1.8\bin;C:\Program Files\JetBrains\IntelliJ IDEA 2021.2\plugins\maven\lib\maven3\bin;C:\Program Files\nodejs\;C:\Windows\System32\Wbem;D:\Redis-x64-3.2.100;C:\Program Files\Go\bin;C:\Program Files\Go\bin;C:\Program Files\OpenSSL-Win64\bin;D:\MinGW-12.2.0\bin;D:\gradle-8.5\bin;D:\hkbea\20231201.PBWMS Enhancement\RmTool\opencv\build\java\x64;C:\Program Files\Tesseract-OCR;C:\Users\cp0612\AppData\Local\Microsoft\WindowsApps;C:\Users\cp0612\AppData\Roaming\npm;C:\Windows\System32\Wbem;C:\Users\cp0612\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\cp0612\go\bin;C:\Program Files\CMake\bin;.
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1989)
at com.hkbea.pbwms.rmtool.MainApp$1.run(MainApp.java:151)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)