← Back to team overview

sikuli-driver team mailing list archive

[Question #691383]: how to use OCR.readLines?

 

New question #691383 on Sikuli:
https://answers.launchpad.net/sikuli/+question/691383

hello, 
first of all, my config is:
2.0.4-2020-03-14_08:01/Windows10.0/Java8(64)1.8.0_251-b08

I have to do OCR on a table, it work rather well if I do it line by line.
I thought it could be faster to do it at once with OCR.readLines and psm = 6 so I tried to read the entire table in an image and then pass it to OCR.readLines.

This is my test code that uses manual screen region selection:
img=selectRegion()
imgFile=capture (img)
OCR.options.psm(6)
lstText=OCR.readLines(img)
print "lstLEN=" + str(len(lstText))
print "lst=" + str(lstText)
for i in range(len(lstText)):
    print "mat="+str( lstText[i])
    print "Txt="+OCR.readLine(lstText[i])
exit(0)

>From the output I see that there are 16 matches, that is correct, but then the
print "Txt="+OCR.readLine(lstText[i])
line gives an error:
error] script [ GM_DTC ] stopped with error in line 127
[error] java.lang.NullPointerException ( java.lang.NullPointerException )
[error] --- Traceback --- error source first
line: module ( function ) statement 
344: Utility (  getLineText )     strOcr = OCR.readLine(rReg, self.options)
127: main (  <module> )     print "Txt="+OCR.readLine(lstText[i])
[error] --- Traceback --- end --------------

I suppose this is a stupid problem from my side, but once obtained the list of matches (as per the docs), how can I extract the strings in it?

Thanks for support

After having set the options (also smallfont)I print them and these are:
OCR.Options:
data = C:\Users\Myself\AppData\Roaming\Sikulix\SikulixTesseract\tessdata
language(eng) oem(3) psm(6) height(10,0) factor(3,00) dpi(96)
variables: user_defined_dpi:300



-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.