findAny() some times founds target and sometimes not

Asked by Nitin Chaudhari on 2019-09-11

Hi Team,
Thanks for support.
Am using SikuliX 1.1.3.
Using findAny() functions in my code many times. Not getting match all the time for the specified target.
Same piece of code works well in other part of implementation.
I tried by setting match from 80% to 95% as well.
Is there any way to get 100% match with findAny? Or other functions.
--------------------------------------------------------
source_check() # Works well.
new_reg = findAny(Pattern("1567587221899.png").similar(0.85),Pattern("1567582102585.png").similar(0.85))
    for match in new_reg :
        match.highlight(1)
        uprint(match.text())
if hostchk == "Connectedto":
        print "Valid Host"
    else :
        wr_sheet.write(rx,23,'Invalid Host')
        type("quit" +Key.ENTER)
        return
--------------------------------------------------------
destn_check() # Unable to find match but find text 'KERBEROSV9 1'
new_reg = findAny(Pattern("1567587221899.png").similar(0.85),Pattern("1567582102585.png").similar(0.85))
    for match in new_reg :
        match.highlight(1)
        uprint(match.text())
if hostchk == "Connectedto":
        print "Valid Host"
    else :
        wr_sheet.write(rx,34,'Invalid Host')
        type("quit" +Key.ENTER)
        return
--------------------------------------------------------

Thanks in advance.
Regards,
Nitin Chaudhari

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2019-10-09
Last query:
2019-10-09
Last reply:
2019-09-11
Best RaiMan (raimund-hocke) said : #1

Might be a timing problem, since findAny does not wait for the image to get visible, but only searches once.

Another problem might be that the image contains too much background, which varies in the fail situation.

Nitin Chaudhari (cnitin) said : #2

Hi Raiman,
I will try to add some wait before findAny(). Also I observed backround impacts the serach.
Hence I always keep notpad as background and run the script. But the application which image need to search is Black.

Is there any workaround to adress this issue? Success of this SikuliX implementaion is dependent on this.
Regards,
Nitin Chaudhari

RaiMan (raimund-hocke) said : #3

Please send me a sample image and a screenshot, so I can test.

sikulix---at---outlook---dot---com

Nitin Chaudhari (cnitin) said : #4

Hi RaiMan,
Am still working on adding wait() before every findAny().
If that works as expected; will share the details.

Thank you once again.
Regards,
Nitin Chaudhari

Nitin Chaudhari (cnitin) said : #5

Hi Raiman,
Thanks for wonderful support.

Adding wait before find() has positive results and it worked.
Appreciate your suggestion...!! Kudos.

Regards,
Nitin Chaudhari

Nitin Chaudhari (cnitin) said : #6

Thanks RaiMan, that solved my question.