text recognition issue when running script from commandline --- use Settings.OcrTextRead = True

Asked by Luiz Carlos Modesto

I wrote a test program:

addImportPath("D:\\SikuliScripts")
import Biblioteca
reload(Biblioteca)
from Biblioteca import *
#----------------------------------------------------------------------------
#
#
def leTexto(reg):
    i = 6
    reg1 = Region(reg)
    reg1.setX(reg.getX()-i)
    reg1.setY(reg.getY())
    reg1.setW(reg.getW()+i)
    reg1.setH(reg.getH()+i)
    reg1.highlight(3)
    resp = decod(reg1.text()).rstrip().lstrip()
    return resp
#
#
Settings.OcrReadText = True
Settings.OcrTextSearch = True
x = selectRegion("Selecione regiao")
y = leTexto(x)
popup("Li texto da NL =" + y)

When I use the IDE it works fine and pops the text up.

But, when I run it from the command line (windows 7) using this:

D:\Sikulix\runsikulix.cmd -f teste.txt -r D:\SikulixScripts\teste1.sikuli

It returns "--- no text read ---"

The log file reads:

[log] highlight R[571,257 232x25]@S(0)[0,0 1366x768] E:Y, T:3,0 for 3.0 secs
[error] text: text recognition is currently switched off

So, it seems ocr is turned on only in the IDE environment, but not in API.

I have Sikulix 1.1.0 installed with tesseract-ocr-3.02.eng.tar.gz

How can I read text in the API?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

the name of the option is:
Settings.OcrTextRead = True

and no:
Settings.OcrReadText = True

it runs in the IDE, because I guess you have the option activated in the Preferences -> more options.

Revision history for this message
Luiz Carlos Modesto (luiz-carlos-modesto) said :
#2

Thanks!

Revision history for this message
Luiz Carlos Modesto (luiz-carlos-modesto) said :
#3

Thanks RaiMan, that solved my question.