not working properly similar

Asked by Chp

Please help me.
Here is my code:
def open_shop(self):
        API.log('open_shop')

        # check if its already opened
        API.log(str(Pattern(Interface.Action['shop_slide']).similar(0.9)))
        shop_slide_match = self.GR.exists(Pattern(Interface.Action['shop_slide']).similar(0.9), 5)
        if shop_slide_match:
            API.log('-------------' + str(shop_slide_match))
            self.click(shop_slide_match.offset(Location(-25, 0)))

here is my log:
P(Game/Action/shop_slide.png) S: 0.9
-------------M[1650,464 85x32]@S(S(0)[0,0 1920x1080]) S:0,71 C:1692,480 [21/21 msec]

how can this be? I say look for an image with similar (0.9) and I found it with (0.71)

it happens when I call the method again

Question information

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

I guess you are using 1.0.1

If you want to stay with that (and not yet upgrade to version 1.1.0), you can try this:

Settings.CheckLastSeen = False

somewhere at the beginning

This switches off the internal pre-check, wether an image is still in place.

In version 1.1.0 this feature is a bit more intelligent.

Revision history for this message
Chp (chpnick) said :
#2

I'm using version 1.1, or rather I try to go at it, I just tried to run in the IDE sikuli, I have observed the exact same problem

Revision history for this message
Chp (chpnick) said :
#3

My code in IDE sikuli:
def open_shop():
        print('open_shop')

        # check if its already opened
        shop_slide = Pattern("shop_slide-2.png").similar(0.90)
        shop_slide_match = exists(shop_slide, 3)
        if shop_slide_match:
            click(shop_slide_match.offset(Location(-25, 0)))
        else:
            # open, may be a slider
            click("building.png")
            shop_slide_match = exists("shop_slide-2.png", 5)
            if shop_slide_match:
                click(shop_slide_match.offset(Location(-25, 0)))
Debug.on(3)
for i in range(4):
    open_shop()
    click("dfsdf.png")

debug(3) log:
open_shop
[debug] Image: reused: shop_slide-2.png (file:/D:/Avto Testing Experiment.sikuli/shop_slide-2.png)
[debug] Region: exists: waiting 3,0 secs for P(shop_slide-2.png) S: 0.9 to appear in R[0,0 1920x1080]@S(0)

[debug] Region: exists: P(shop_slide-2.png) S: 0.9 has not appeared [877 msec]
[debug] Region: find: waiting 3,0 secs for building.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: building.png (file:/D:/Avto Testing Experiment.sikuli/building.png)

[debug] Region: find: building.png has appeared at M[1703,468 28x24]@S(S(0)[0,0 1920x1080]) S:1,00 C:1717,480 [501/501 msec]
[debug] CLICK on L(1717,480)@S(0)[0,0 1920x1080]

[debug] Region: exists: waiting 5,0 secs for shop_slide-2.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: shop_slide-2.png (file:/D:/Avto Testing Experiment.sikuli/shop_slide-2.png)

[debug] Region: exists: shop_slide-2.png has not appeared [1080 msec]
[debug] Region: find: waiting 3,0 secs for dfsdf.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: dfsdf.png (file:/D:/Avto Testing Experiment.sikuli/dfsdf.png)

[debug] Region: find: dfsdf.png has appeared at M[1494,329 35x29]@S(S(0)[0,0 1920x1080]) S:0,96 C:1511,343 [370/370 msec]
[debug] CLICK on L(1511,343)@S(0)[0,0 1920x1080]

open_shop
[debug] Image: reused: shop_slide-2.png (file:/D:/Avto Testing Experiment.sikuli/shop_slide-2.png)
[debug] Region: exists: waiting 3,0 secs for P(shop_slide-2.png) S: 0.9 to appear in R[0,0 1920x1080]@S(0)

[debug] Region: exists: P(shop_slide-2.png) S: 0.9 has not appeared [920 msec]
[debug] Region: find: waiting 3,0 secs for building.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: building.png (file:/D:/Avto Testing Experiment.sikuli/building.png)

[debug] Region: checkLastSeen: still there
[debug] Region: find: building.png has appeared at M[1703,468 28x24]@S(S(0)[0,0 1920x1080]) S:1,00 C:1717,480 [60/60 msec]
[debug] CLICK on L(1717,480)@S(0)[0,0 1920x1080]

[debug] Region: exists: waiting 5,0 secs for shop_slide-2.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: shop_slide-2.png (file:/D:/Avto Testing Experiment.sikuli/shop_slide-2.png)

[debug] Region: exists: shop_slide-2.png has appeared at M[1650,464 85x32]@S(S(0)[0,0 1920x1080]) S:0,71 C:1692,480 [972/640 msec]
[debug] Device: Mouse: moved externally: now (1799,441) was (1717,480) (mouseMovedResponse 0)
[debug] CLICK on L(1667,480)@S(0)[0,0 1920x1080]

[debug] Region: find: waiting 3,0 secs for dfsdf.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: dfsdf.png (file:/D:/Avto Testing Experiment.sikuli/dfsdf.png)
[debug] Region: checkLastSeen: still there
[debug] Region: find: dfsdf.png has appeared at M[1494,329 35x29]@S(S(0)[0,0 1920x1080]) S:0,99 C:1511,343 [63/63 msec]
[debug] CLICK on L(1511,343)@S(0)[0,0 1920x1080]

open_shop
[debug] Image: reused: shop_slide-2.png (file:/D:/Avto Testing Experiment.sikuli/shop_slide-2.png)
[debug] Region: exists: waiting 3,0 secs for P(shop_slide-2.png) S: 0.9 to appear in R[0,0 1920x1080]@S(0)
[debug] Region: checkLastSeen: still there
[debug] Region: exists: P(shop_slide-2.png) S: 0.9 has appeared at M[1650,464 85x32]@S(S(0)[0,0 1920x1080]) S:0,71 C:1692,480 [54/54 msec]
[debug] CLICK on L(1667,480)@S(0)[0,0 1920x1080]

[debug] Region: find: waiting 3,0 secs for dfsdf.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: dfsdf.png (file:/D:/Avto Testing Experiment.sikuli/dfsdf.png)

[debug] Region: checkLastSeen: not there

[debug] Region: find: dfsdf.png has not appeared [1030 msec]
[error] script [ Avto Testing Experiment ] stopped with error in line 18
[error] FindFailed ( can not find dfsdf.png in R[0,0 1920x1080]@S(0) )
[debug] Sikulix: cleanUp: 0

[debug] save image for copy&paste: shop_slide-2.png -> /D:/Avto Testing Experiment.sikuli/shop_slide-2.png
[debug] save image for copy&paste: building.png -> /D:/Avto Testing Experiment.sikuli/building.png
[debug] save image for copy&paste: shop_slide-2.png -> /D:/Avto Testing Experiment.sikuli/shop_slide-2.png
[debug] save image for copy&paste: dfsdf.png -> /D:/Avto Testing Experiment.sikuli/dfsdf.png

[debug] save image for copy&paste: shop_slide-2.png -> /D:/Avto Testing Experiment.sikuli/shop_slide-2.png
[debug] save image for copy&paste: building.png -> /D:/Avto Testing Experiment.sikuli/building.png
[debug] save image for copy&paste: shop_slide-2.png -> /D:/Avto Testing Experiment.sikuli/shop_slide-2.png
[debug] save image for copy&paste: dfsdf.png -> /D:/Avto Testing Experiment.sikuli/dfsdf.png

Revision history for this message
Chp (chpnick) said :
#4

I try to translate my test system with sikuli rc930 on sikuli 1.1 and here I was faced with such a problem. Could this be due to the fact that I found two versions sikuli

Revision history for this message
RaiMan (raimund-hocke) said :
#5

ok, thanks.
made it a bug for now.
I will check it.

Revision history for this message
RaiMan (raimund-hocke) said :
#6

@ comment #4:
should not be, since version 1.1.0 (at least builds newer than April 2015) can no longer collide with older versions on same system.

Revision history for this message
Chp (chpnick) said :
#7

Do I understand correctly that this error sikuli 1.1? I'll try to run with the parameter Settings.CheckLastSeen = False, and see how it will work, I also try to download the update right now today and also try

Revision history for this message
RaiMan (raimund-hocke) said :
#8

ok, found the reason for this behavior:

the "LastSeen" information is stored with the used image.

Since the first time, "shop_slide-2.png" was found is in the else branch with
 shop_slide_match = exists("shop_slide-2.png", 5)

where you do not use the Pattern, so finding with 0.71 is allowed.

this information is stored with the image and it seems, that when using the same image in the
shop_slide_match = exists(shop_slide, 3)

it is evaluated as being still there, but the wanted minimum score of 0.9 is apparently ignored here.

I will check and fix that.

as a workaround for now do this:

     # check if its already opened
        shop_slide = Pattern("shop_slide-2.png").similar(0.90)
        Settings.CheckLastSeen = False
        shop_slide_match = exists(shop_slide, 3)
        Settings.CheckLastSeen = True
        if shop_slide_match:
….

No need to switch it off generally, since in the other cases it works like it should (search about 10 times faster)

Revision history for this message
RaiMan (raimund-hocke) said :
#9

ok, crossed ;-)

Revision history for this message
Chp (chpnick) said :
#10

I helped setting Settings.CheckLastSeen = False and all now works correctly, and tell it exactly does Settings.CheckLastSeen = False?

Revision history for this message
RaiMan (raimund-hocke) said :
#11

I tried to explain the CheckLastSeen-feature in comment #8 !!??

Revision history for this message
Chp (chpnick) said :
#12

Thank you very much I will wait for correction, I understand that if ignored similar to this was found with another similar image. How do I know when it is fixed? So far I've just put the same similar for both searches

Revision history for this message
Chp (chpnick) said :
#13

I still want to ask here about such a thing, in the old IDE button displacement target was shown the screen itself http://joxi.ru/E5md1Zquaqxj21, it is convenient to determine the offset and again that there is no http://joxi.ru/jgmv1GWudepgra

Revision history for this message
RaiMan (raimund-hocke) said :
#14

In the TargetOffset tab of preview the whole screen is only shown, if the given image is visible on the current screen at time of Preview.

Otherwise since beginning only the image is shown (since nothing else is known at that time).

Revision history for this message
Chp (chpnick) said :
#15
Revision history for this message
RaiMan (raimund-hocke) said :
#16

Sorry, but I do not understand.

comment #14 is true for version 1.0.1+

Do you want to say, that the screen is shown on the targetOffset tab of Preview with RC3 IDE, though the image is not visible on the screen?

Revision history for this message
Chp (chpnick) said :
#17

http://joxi.ru/K823WQoHaw972O
http://joxi.ru/48AnayqCoKzJ2O
If you do not understand something, I'll write you a video

Can you help with this problem?

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

To post a message you must log in.