1.1.1 and 2.0.4 on same machine: ocr tessdata gets corrupted for 1.1.1

Asked by Sona on 2020-05-10

Hi Raiman sir,
I am using sikulixapi 1.1.1 jar file with java. I am using JDK 1.6 update 25 for java.

Everything like "find", "click", etc. works file with sikulixapi1.1.1 but when I am doing region.text() in java using sikuli, my java program terminates with error in java output console as following:

"Problematic frame: # C[libtessaract-3.dll+ 0x189732]..................... actual_tessdata_num_entries_<=TESSDATA_NUM_ENTRIES:Error:Assert failed:in file tessdatamanager.cpp,

Actually, there is no problem of tessdata if I use sikulixapi2.0.4 with my java program.. But sikulixapi 2.0.4 requires java/jre 8... I want to stick to jre 6 update 25..
Please tell me the detailed procedure for including the tessdata into sikulixapi1.1.1. Please tell me where to incluse the tessadata in sikulixapi1.1.1. I do not know much about maven repository etc.. So please tell me in detail.. This will be of immense help and life saviour for me..
 Thanks in advance..

Question information

English Edit question
SikuliX Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

are you using 1.1.1 and 2.0.4 on the same machine?

what system?

Sona (sonaindia) said : #2

Yes I am using sikulixapi 1.1.1 & sikulixapi2.0.4 on same machine.... Just importing sikulixapi into my java program at a time(not both at the same time).

My computer is windows 10, 64 bit.

Please help me sir.

RaiMan (raimund-hocke) said : #3

the problem ist that 2.0.4 overwrites the tessdata files in <APPDATA>/Sikulix/SikulixTesseract which are not backward compatible.

1.1.1 does not check the tessdata content nor does it restore the files if the folder exists.

So try this:
before switching back to using 1.1.1, delete the folder <APPDATA>/Sikulix/SikulixTesseract/tessdata.
It then should be restored with the 1.1.1 stuff.

Sona (sonaindia) said : #4

Thanks Raiman,
Thanks for your suggestion, it worked in my previous computer. Here are few of my observations in a new computer:
1. In another fresh computer(sikulix was not installed here, Widows 7, 32 bit), while using sikulixapi1.1.1 with jdk 1.6 update 25, it gave me following error:
java.lang.UnsupportedClassVersionError: org/sikuli/script/FindFailed : Unsupported major.minor version 51.0
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
 at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: AutoMLoopTest. Program will exit.
Exception in thread "main" Java Result: 1

2. As I could not use sikulixapi1.1.1, I used sikulixapi1.1.0 with java, then I found the error that User/AppData/.../tessdata folder not found, then I unzipped the sikulixapi1.1.1 and took its sikuli tessdata folder and pasted it to sikulixapi1.1.0 and created a new jar of sikulixapi1.1.0. I ran the program, it ran, but text recognition was not good.

3. I again used sikuxapi2.0.4 with java, but this time I got this error:

[error] RunTime:loadLib: opencv_java342.dll (failed) probably dependent libs missing:
C:\Users\ARIJIT\AppData\Roaming\Sikulix\SikulixLibs\opencv_java342.dll: Can't find dependent libraries
[error] Save your work, correct the problem and restart the IDE!
[error] see: https://github.com/RaiMan/SikuliX1/wiki/macOS-Linux:-Support-Libraries-for-OpenCV-4
Exception in thread "main" java.lang.ExceptionInInitializerError
TERMINATING: problem with native library: opencv_java342.dll
 at org.sikuli.script.Finder$FindInput2.<clinit>(Finder.java:1164)
 at org.sikuli.script.Finder.<init>(Finder.java:34)
 at org.sikuli.script.Region.doCheckLastSeenAndCreateFinder(Region.java:2841)
 at org.sikuli.script.Region.checkLastSeenAndCreateFinder(Region.java:2802)
 at org.sikuli.script.Region.doFind(Region.java:2731)
 at org.sikuli.script.Region.find(Region.java:2271)
 at AutoMLoopTest.main(AutoMLoopTest.java:710)
Caused by: org.sikuli.script.SikuliXception: fatal: problem with native library: opencv_java342.dll
 at org.sikuli.script.support.RunTime.terminate(RunTime.java:1317)
 at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1532)
 at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1689)
 at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:536)
 ... 7 more

Let me tell you that, I will not install sikulix.. I will just use sikulixapi.jar with java.

Sona (sonaindia) said : #5

Sir, one more thing I do not want any fancy feature. just minimal feature for find image and good recognition of text(ocr). Please tell me the minimum version of the files I need. Again let me tell you, I do not want my friends to install sikuli. Just my java jar program and sikulixapi with its dependencies. thats all I want to bundle.

RaiMan (raimund-hocke) said : #6

I fully understand your request.

... but looking back into the history:

- IMHO: 1.1.1 needs at least Java 7
- 1.1.0 should work with Java 6

The OCR/text features with the 1.1.x releases had many problems and did not deliver good results in many cases.

I cannot help due to lack of time and resources for digging back into the past.

If you really want to stick with your plans, you have to work with the sources:

There you can find the releases 1.1.0 and 1.1.1.

And regarding Tesseract you have to dive into the gory details yourself.

Sona (sonaindia) said : #7

Ok Raiman Sir,
Thanks for your kind suggestion... I spent 2 hours thinking what should I do? Should I go for sikulixapi2.0.4 with jdk 8(along with java) or should I try something else for desktop automation along with java.... Sir, basically I spent many sleepless( :) ) nights for developing desktop automation by sikulixapi with java. Now that my program with sikulixapi2.0.4 works to near perfection (100% in find image and 98 % in ocr recognition), I decided to go for sikulixapi2.0.4(I know its little bulky around 54 MB) with JDK 1.8(I also have to bundle jre 8 along with the program to my friends as most of them work in jre 6 or at most jre 7).

Thats being all said, now the problem arises, along with sikulixapi2.0.4(in lib folder) and my program jar file, what else I need to bundle? so that my program runs in a completely new pc with jre 8 installed. Any additional softwares(opencv, etc) are required?

Best RaiMan (raimund-hocke) said : #8

As long as it is a Windows 64-Bit machine with a JRE 8 64-Bit version installed: that is all you need (32-Bit is no longer supported).

If Mac support and/or Linux support is needed:
Have a look at the respective articles: https://github.com/RaiMan/SikuliX1/wiki

Hope you get on the road.

Sona (sonaindia) said : #9

Thanks RaiMan Sir,
Now I can use sikulixapi2.0.4 with jre 1.8 in 64 bit PC
Also I could use sikulixapi1.1.0 with jre 1.6 in both 32 bit and 64 bit PC

Thanks Raiman Sir, for building such awesome desktop automation tool

Sona (sonaindia) said : #10

Thanks RaiMan, that solved my question.