RaiMan / SikuliX1

SikuliX version 2.0.0+ (2019+)
https://sikulix.github.io
MIT License
2.73k stars 349 forks source link

Java: sikulixapi: Tesseract library problems #503

Closed haogubang closed 2 years ago

haogubang commented 2 years ago

Run Environment: Windows Server 2019, java 1.8.0_311, Microsoft Visual C++ 2015 Redistributable (x64)

when i use sikulixapi in my java project, occurred exception:

[error] see: https://github.com/RaiMan/SikuliX1/wiki/Windows:-Problems-with-libraries-OpenCV-or-Tesseract [error] Save your work, correct the problem and restart the IDE! Exception in thread "main" org.sikuli.script.SikuliXception: OCR: start: Tesseract library problems: The specified module could not be found

    at org.sikuli.script.TextRecognizer.getTesseractAPI(TextRecognizer.java:131)
    at org.sikuli.script.TextRecognizer.doRead(TextRecognizer.java:376)
    at org.sikuli.script.TextRecognizer.readText(TextRecognizer.java:335)
    at org.sikuli.script.OCR.readText(OCR.java:710)
    at org.sikuli.script.OCR.readText(OCR.java:695)
    at org.sikuli.script.Element.text(Element.java:150)

following are all jars in the project:

commons-collections-3.2.1.jar commons-io-1.3.2.jar commons-lang3-3.3.2.jar commons-logging-1.1.3.jar druid-1.0.20.jar eova-1.6.0.jar fastjson-1.2.59.jar httpclient-4.3.6.jar httpcore-4.3.2.jar jai-imageio-core-1.4.0.jar jfinal-3.6-bin.jar jna-5.6.0.jar jna-platform-5.6.0.jar jsoup-1.11.3.jar lept4j-1.13.2.jar mysql-connector-java-5.1.20-bin.jar opencv-4.3.0-3.jar sikulixapi-2.0.5-sources.jar sikulixapi-2.0.5.jar slf4j-api-1.7.30.jar slf4j-simple-1.7.32.jar tess4j-4.5.5.jar webmagic-core-0.5.2.jar xsoup-0.2.4.jar

fturhan commented 2 years ago

I have the same issu with sikulixIDE 2.0.5 working with python script on windows 7 (java 1.8 installed)

RaiMan commented 2 years ago

tested with a Maven project in IntelliJIDEA on Win11 with Java 17 (other Java versions 8+ should not make a difference):

import org.sikuli.script.*;
import org.sikuli.script.support.Commons;

import java.io.File;

public class Test {
   public static void main(String[] args) {
      Screen scr = new Screen();
      File workDir = Commons.getWorkDir();
      ImagePath.setBundlePath(new File(workDir, "/src/main/resources/images").getAbsolutePath());
      Commons.info("%s", ImagePath.getBundlePath());
      Commons.info("%s", scr.exists("img")); // an image containing text
      Commons.info("%s", scr.getLastMatch().text());
      Commons.info("");
   }
}

The dependency I used:

<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>2.0.5</version>

At runtime everything needed on Windows is available in the project (through Maven dep management)

le-ross commented 1 year ago

Is there a worksaround? I having the same issues here but not sure how to read this thread.