Cannot make OCR work with 1.1.4

Asked by Finn Andresen

I am trying to validate whether Sikulix could be a tool used at work for testing UI (browser application) but I can not get the OCR functionality to work. When using 1.1.3 I can get the region.text() method to return the text from the selected region, but with 1.1.4 I get very arbitrary results - most often text() doesn't return anything and len(words) returns 0, but sometimes something is returned but definitely not the selected text.

What am I doing wrong here?

*** Simple program code from IDE ***

Settings.UserLogs=True
Settings.ActionLogs=True
Settings.InfoLogs=True
Settings.OcrReadText=True
Settings.OcrTextRead=True
Debug.on(5)

region=selectRegion()
Debug.user("Region: %s", region)
Debug.user("Text: %s", region.text())

#
# Below part fails with 1.1.3 as the functionality is new to 1.1.4
#
words=region.collectWords()
Debug.user("Number of matched words: %d", len(words))
for matchWord in words:
    Debug.user("Mathed word: %s", matchWord.getText())
    matchWord.highlightOn()
    sleep(1)

sleep(5)

***** Corresponding output selecting "What is SikuliX text" from the sikulix.com page *****

[debug] RobotDesktop: captureScreen: [0,0, 2560x1440]
[debug] ScreenImage.store: C:\Users\finna\AppData\Roaming\Sikulix\SikulixStore\lastScreenShot.png
[debug] CapturePrompt: started at (986,950) as L(986,950) on 0
[debug] CapturePrompt: finished at (1687,1063) as L(1687,1063) on 0
[debug] CapturePrompt.close: S(0) freeing resources
[user (16-09-19 21:44:30)] Region: R[986,950 702x114]@S(0)
[debug] RobotDesktop: captureScreen: [986,950, 702x114]
[debug] RunTime:addToWindowsSystemPath: added to systempath:
C:\Users\finna\AppData\Roaming\Sikulix\SikulixLibs
[debug] RunTime:checkJavaUsrPath: added to ClassLoader.usrPaths
[debug] RunTime:libsExport: folder exists: C:\Users\finna\AppData\Roaming\Sikulix\SikulixLibs (1.1.4 - 201909130835)
[debug] RunTime:loadLib: opencv_java342.dll (success)
[debug] TextRecognizer: start: data folder: C:\Users\finna\AppData\Roaming\Sikulix\SikulixTesseract\tessdata
[debug] TextRecognizer: start: language: eng
[user (16-09-19 21:44:32)] Text: :§§E§% g駧i

[debug] RobotDesktop: captureScreen: [986,950, 702x114]
[debug] Finder2: doFindText: listWords: 2 words (2455 msec)
[user (16-09-19 21:44:35)] Number of matched words: 2
[user (16-09-19 21:44:35)] Mathed word: :§§E§%
[debug] highlight M[986,1006 416x47]On(0) S 3501 for 0.0 secs
[user (16-09-19 21:44:36)] Mathed word: g駧i
[debug] highlight M[1276,1006 412x47]On(0) S 3679 for 0.0 secs
1.1.4-SNAPSHOT-#380-2019-09-13_08:35/Windows10.0/Java8(64)1.8.0_221-b11
1.1.4-SNAPSHOT-#380-2019-09-13_08:35/Windows10.0/Java8(64)1.8.0_221-b11

Question information

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

use the latest 1.1.4 build #381

OCR did not work any more - fixed now.

Revision history for this message
Finn Andresen (finnandresen) said :
#2

Sorry for the late response. With build #381 this functionality now works for me. Thanks for the swift fix.