Settings variables imported from jnius autoclass does not take effect.

Asked by Lee Tze Keong on 2017-12-28

I am using python + jnius + sikulix-1.1.1 to develop my script.

The code that I am using is as below:

from jnius import autoclass

Settings = autoclass('org.sikuli.basics.Settings')
Region = autoclass('org.sikuli.script.Region')

Settings.OcrTextRead = True
Settings.OcrTextSearch = True
print Settings.OcrTextRead
print Settings.OcrTextSearch
print Region(377, 60, 100, 14).text()

The output is as below:

[error] text: text recognition is currently switched off

Any help on this problem?

Question information

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

I guess the problem with this Python wrapper is, that the line
Settings.OcrTextRead = True

does not really change the value in the original org.sikuli.basics.Settings class, but in some proxy.

So the internal function Region.text() does not see the change.

I have no idea, how to solve that.

Why don't you use Jython?

Be aware: before getting deeper into this solution, test with the SikuliX IDE, wether the text feature works as you expect in your situation (has many problems)

Lee Tze Keong (tklee) said : #2

This is part of an existing python project, so using a python wrapper will save a great amount of job.

I know OCR may have problems like mixing up some characters, so I still deciding whether to use it or not.

Maybe I chose a bad example using OCR, but what I really mean is unable to change the values in the original Settings class hurts.

Best RaiMan (raimund-hocke) said : #3

ok, thanks for information. understood and accepted.

I changed the Settings.OCR... to true in the latest 1.1.2 nightly Build 92 (, since the tessdata stuff now is always available (option 3 in setup 1.1.2 now obsolete).

So you might try with this.

All the best.

Lee Tze Keong (tklee) said : #4

Thanks RaiMan, that solved my question.