[1.1.3] findAll fails but image exists --- workaround --- fixed in 1.1.4

Bug #1833356 reported by Jeff_Vallis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Confirmed
Undecided
RaiMan

Bug Description

******************************** workaround

;-) best workaround is to use 1.1.4

for 1.1.3:
using exists(), wait() or find() and getting a similarity score of x, then with findAll() the same image might come up with a score of x - 0.03 down to x - 0.1.

so using

exists(Pattern(someImage).similar(score))

then this will assure, to come back with the same result (first match):

findAll(Pattern(someImage).similar(score - 0.1))

----------------------------------------------------

Code
def Find_All_Close_X(v_Image):
    if exists(v_Image,0.2):
        v_Pos = find(v_Image)
        print "v_Pos",v_Pos
        hover(Location(v_Pos.x,v_Pos.y))
        print "hovering",v_Pos.x,v_Pos.y
        popup("Found and hovering")
        v_Result = findAll(v_Image)
    else:
        print "Not Found"
v_Image_p = "/home/jeff/SikuliScripts_Linux/Subs/Vikings/Close X big Region.png"
sx = 422 ; sy = 132 ; sw = 505 ; sh = 270
setRect(sx,sy,sw,sh)
g_Find_Matching = 0.85
for i in range(20):
    print "^ " * 40 ,"Try", g_Find_Matching
    v_Image = Pattern(v_Image_p).similar(g_Find_Matching)

    Find_All_Close_X(v_Image)
    g_Find_Matching = g_Find_Matching - 0.01

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :
Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

Image

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

Have been fighting this for ages
findAll fails at similiar 0.80
I added this bit of code to try to debug
######################
        v_Pos = find(v_Image)
        print "v_Pos",v_Pos
        hover(Location(v_Pos.x,v_Pos.y))
        print "hovering",v_Pos.x,v_Pos.y
        popup("Found and hovering")
#######################
my results :-

^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try 0.85
Not Found
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try 0.84

Not Found
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try 0.83

Not Found
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try 0.82

Not Found
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try 0.81

v_Pos M[457,191 8x11]@S(S(0)[0,0 1366x768]) S:0.82 C:461,196 [80 msec]

hovering 457 191

[error] script [ FindFailed ] stopped with error in line 19
[error] FindFailed ( /home/jeff/SikuliScripts_Linux/Subs/Vikings/Close X big Region.png: (8x11) seen at (457, 191) with 0.82 in S(0)[0,0 1366x768] E:Y, T:3.0 )
[error] --- Traceback --- error source first
line: module ( function ) statement
8: main ( Find_All_Close_X ) v_Result = findAll(v_Image)
[error] --- Traceback --- end --------------

1.1.3(2018-06-07_14:48)/Linux4.15.0-48-generic/Java8(64)1.8.0_201-b09

Revision history for this message
RaiMan (raimund-hocke) wrote : Re: [1.1.3] findAll fails but image exists

the screen shot does not contain any close button.

summary: - findAll Fails
+ [1.1.3] findAll fails but image exists
RaiMan (raimund-hocke)
Changed in sikuli:
status: New → Opinion
milestone: none → 1.1.4
importance: Undecided → Low
assignee: nobody → RaiMan (raimund-hocke)
Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

Thanx

Perhaps I should have said that the image should not match but on
exist and find it matches the % image on the screen at 0.81 which is something I can deal with.

What I need and I imagine all users need is for matching to be consistant on exist find and findAll and if exists or find gets a match then findAll has the same result.

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

While you at it is there any chance that you can get the logging changed
If I Hover - and maybe Drag and Drop I get the following

[error] RobotDesktop: checkMousePosition: should be L(1048,274)@S(0)[0,0 1920x1080]
but after move is L(1166,681)@S(0)[0,0 1920x1080]
Possible cause in case you did not touch the mouse while script was running:
 Mouse actions are blocked generally or by the frontmost application.

It seems like its now aware of the mouse movement

Its just annoying and not a big thing
(Its been going from when I first started using Sikuli)

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

Any update on this.

My work around at present is very slow and doesn't always succeed

Work around

if Exists with no matching
findAll with no matching
setRect for each foundAll
see if exists with matching for same image : if so add to an array

I think that my work around doesn't always work as my GUESS is that findAll has a limit of 100 items

Just out of interest what I am trying to do is find a white number 1 in a green circle with a yellow border.

Pity I cant match circles as well as rectangles
So my image is just the number 1 on green background

there are a lot of white number 1's on the screen and a lot of boxes many of which are rectangles
trying to find white number 1 with no matching find both sides of rectaangles as well as number 1 and many times findAll returns 100 matches and none of them is number 1 with matching at 0.90

Revision history for this message
RaiMan (raimund-hocke) wrote :

Though I do not support 1.1.3 anymore:

Please send me a screenshot and the images you are trying with.
sikulix---at---outlook---dot---com

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

Mail sent

Revision history for this message
Jeff_Vallis (vallis-pj) wrote : Re: [Bug 1833356] Re: [1.1.3] findAll fails but image exists

The screen.
        This could contain a close button or many close buttons if a pop up
window called another pop up window hence the code if exists find them all
and keep closing till the pop ups are gone or in the actual code it has
tried 20 times to prevent an infinite loop.
The problem.
        Exists finds a match. The match it finds is on the screen it’s not
a close button it’s a % which in pixels must be very similar.
        You can see from the test code that I wrote that I found what it
was matching by using find which also found the match and positioning the
cursor at that position. After which I did a pop up to see the match and
then it did the findall which crashes

On Wed, Jun 19, 2019 at 9:01 AM RaiMan <email address hidden> wrote:

> the screen shot does not contain any close button.

>
> ** Summary changed:
>
> - findAll Fails
> + [1.1.3] findAll fails but image exists
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1833356
>
> Title:
> [1.1.3] findAll fails but image exists
>
> Status in Sikuli:
> New
>
> Bug description:
> Code
> def Find_All_Close_X(v_Image):
> if exists(v_Image,0.2):
> v_Pos = find(v_Image)
> print "v_Pos",v_Pos
> hover(Location(v_Pos.x,v_Pos.y))
> print "hovering",v_Pos.x,v_Pos.y
> popup("Found and hovering")
> v_Result = findAll(v_Image)
> else:
> print "Not Found"
> v_Image_p = "/home/jeff/SikuliScripts_Linux/Subs/Vikings/Close X big
> Region.png"
> sx = 422 ; sy = 132 ; sw = 505 ; sh = 270
> setRect(sx,sy,sw,sh)
> g_Find_Matching = 0.85
> for i in range(20):
> print "^ " * 40 ,"Try", g_Find_Matching
> v_Image = Pattern(v_Image_p).similar(g_Find_Matching)
>
> Find_All_Close_X(v_Image)
> g_Find_Matching = g_Find_Matching - 0.01
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/sikuli/+bug/1833356/+subscriptions
>

RaiMan (raimund-hocke)
Changed in sikuli:
status: Opinion → Invalid
milestone: 1.1.4 → none
importance: Low → Undecided
Revision history for this message
Jeff_Vallis (vallis-pj) wrote : Re: [1.1.3] findAll fails but image exists
Download full text (3.6 KiB)

Disagree
Bug Exists
1.1.3(2018-07-05_16:27)/Mac10.13.6/Java8(64)1.8.0_25-b17
workaround
code

def Test_findAll(v_Image):
    v_Array = [] ; v_Result = 0
    if exists(v_Image,0.2):
        print "Image exists"
    else:
        print "Not Found"
        return v_Result,v_Array
    try:
        v = findAll(v_Image)
        v_Array = list(v)
        v_Result = 1
        print "findAll successful"
        print len(v_Array),"Items"
    except:
        v_Array = []
        if str(sys.exc_info()[0]).find("FindFailed",0)>0:
            print "@ " * 40
            print "sikuli bug image exists but findAll Fails"
            print "@ " * 40
            v_Result = 2
        else:
            print "$ " * 40
            print("Oops! unknown error",sys.exc_info()[0],"occured.")
            print "$ " * 40
            v_Result = 3
    finally:
        return v_Result,v_Array

def Find_All(v_Image):
    v_Result,v_Array = Test_findAll(v_Image)
    #print "v_Result,v_Array",v_Result,len(v_Array)
    if v_Result == 0:
        print "Not Exists"
    if v_Result == 1:
        print "Exists and finAll successful"
        exit(0)
    if v_Result == 2:
        print "Exists sikuli bug findAll failed"
    if v_Result == 3:
        print "findAll Other Error force Crash"
        print "findAll Other Error force Crash", 1/0

# print "Next but exit" ; exit(0)

#v_Image_p = "Close X big Region.png"
v_Image_p = "Close X big Region.png"
sx = 16 ; sy = 292 ; sw = 1076 ; sh = 443
setRect(sx,sy,sw,sh)
g_Find_Matching = 0.75

for i in range(20):
     print "^ " * 40 ,"Try with matching", g_Find_Matching
     v_Image = Pattern(v_Image_p).similar(g_Find_Matching)

     Find_All(v_Image)
     g_Find_Matching = g_Find_Matching - 0.01

output

^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0.75

Not Found
Not Exists
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0.74

Not Found
Not Exists
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0.73

Not Found
Not Exists
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0.72

Not Found
Not Exists
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0.71

Not Found
Not Exists
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0.7

Image exists

@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
sikuli bug image exists but findAll Fails
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
Exists sikuli bug findAll failed
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0.69

Image exists

@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
sikuli bug image exists but findAll Fails
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
Exists sikuli bug findAll failed
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Try with matching 0...

Read more...

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

and the image

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

perhaps you are not running in exactly the same environment as me
or different version of sikuli
1.1.3(2018-07-05_16:27)/Mac10.13.6/Java8(64)1.8.0_25-b17
I can produce this bug on this machine and also on my Linux Laptop
and because the image on the laptop is different icrashes at a different degree of matching

but I always get in output

Image exists

@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
sikuli bug image exists but findAll Fails
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
Exists sikuli bug findAll failed

Revision history for this message
Jeff_Vallis (vallis-pj) wrote :

Now on holiday for 2 weeks

RaiMan (raimund-hocke)
Changed in sikuli:
status: Invalid → Confirmed
summary: - [1.1.3] findAll fails but image exists
+ [1.1.3] findAll fails but image exists --- workaround
Revision history for this message
RaiMan (raimund-hocke) wrote :

All the best for your holidays.

I made some tests now with 1.1.3 and have to admit, that exists() and findAll() might not always give the same result.

See the documented workaround.

summary: - [1.1.3] findAll fails but image exists --- workaround
+ [1.1.3] findAll fails but image exists --- workaround --- fixed in 1.1.4
RaiMan (raimund-hocke)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.