How to validate animation?

Asked by donatelo

Hello,

In my web application I have an animation, lets say that an object (square) is moving on the screen from point A to point B. I would like to veryfy that my object (square) appears somewhere beetween points A and B (that let me assume that the object was really animated and moved from A to B).

I did screenshot in which my object is somewhere between point A and B. And I tried to validate it that way (so I'm waiting for exact match)

objectMoving = Pattern("objectMoving.png").similar(0.99)

if wait(objectMoving , 10):
    print "picture visible"
else:
    print "picture not visible"

Unfortunetly, athough my object is really moving from A to B and for sure every time I run the script it matches screen given as objectMoving.png, I'm sometimes getting "picture visible" and sometimes "picture not visible". So it seems that sikuli is not able to recognize it every time. My object will match view in objectMoving.png only once (in given for wait 10 seconds).

Any sugestion how to handle this issue?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
obiwan-92
Solved:
Last query:
Last reply:
Revision history for this message
Best obiwan-92 (obiwan-92) said :
#1

Hello.

Take a screenshoot of your object without any background at all.

Then define the region between the point A and B.
For example : r = Region(xA, yA, xB-xA, yB-yA) # where xA, yA and xB, yB are the coordinates of your two points.

Your code should be something like this :
try:
    r.wait(objectMoving , 10)
    print "picture visible"
except:
   print "picture not visible"

Or :
if r.exists(objectMoving): print "picture visible"
else: print "picture not visible"

It should be work ;)
Regards.

Revision history for this message
donatelo (donatelo) said :
#2

Thanks! Works much more better with region and this approach
try:
    r.wait(objectMoving , 10)
    print "picture visible"
except:
   print "picture not visible"

Unfortunately, 1 of 7 attempts fails (sikuli is not able to find pattern), but it is better than my solution without Region :)

Revision history for this message
donatelo (donatelo) said :
#3

Thanks obiwan-92, that solved my question.