Text can be found with region.text() but not with region.exists()

Asked by Jenny Biekman

Hello,

We're trying to use text recognition, but the results are inconsistent.
Our application windows have tabs and we want to read those tabs to check that the window has opened and that it's the right one.
To do that we've made a region called tabs and we ask it if the right tab exists with tabs.exists("name_of_tab").
With some names it works, and with some names it doesn't.
Because of this we thought that perhaps those names that didn't work couldn't be recognised, so we turned it around and asked tabs to tell us what it saw with print tabs.text().
When we do this it recognises every name perfectly.
How can we get every name to be recognised when using tabs.exists("name_of_tab")?

We use Sikuli 1.1.0
This is our code:

# Find tab Key2Wocas, and turn it into the base region the other regions will be based on
def regio():
    global r
    r = Region(find("Key2Woca.png"))
    r = r.right(27)
    r = r.nearby(10)

# Make a new region to the right of the base region. This is where the tabs will be found
def regio_tabs():
    regio()
    global tabs
    tabs=r.right()
    tabs.highlight(1)
    print tabs.text()

# Check to see if the the right tab exists in the region tabs
def tab_aanwezig(tekst):

    regio_tabs()
    t = tekst

    if not tabs.exists(t):
        wait(3)

    m = tabs.exists(t)
    if m:
        print "Tabblad " + t + " is geopend."
    else:
        print "Tabblad " + t + " is niet binnen 3 seconden gevonden; het script wordt gestopt."
        exit()

tab_aanwezig("Basisregistratie")

Question information

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

Currently I do not have a solution for you.

the two features Region.find("some text") and Region.text() internally are using completely different approaches, so it is "normal", that they might end up with different results.
Since the text features formally are still at some alpha level and not very reliable, you currently have to live with these inconsistencies.

Only later this year with version 2 I will touch and revise the text/OCR features.

Revision history for this message
Jenny Biekman (jenny-kuiper-biekman) said :
#2

Thank you for your explanation.
We'll try to find a workaround to get the results we want until version 2.0 is released.

Can you help with this problem?

Provide an answer of your own, or ask Jenny Biekman for more information if necessary.

To post a message you must log in.