← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #694607]: Pattern.resize() issue driving me nuts!

 

Question #694607 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/694607

    Status: Answered => Open

Simon Plivav is still having a problem:
Hi RaiMan, ty for the response! My search pattern is (676, 41), my
search region is SCREEN which is in my case (1366x768). So, a .find()
operation should work from that perspective, shouldn't it? I don't
understand where Sikulix is getting the "(672, 40)" from - I have not
specified such object or dimension explicitely, not via a Region(),
ROI(), nor a Rectangle() statement.

Why is it replacing the 'SCREEN' in "numScore = SCREEN.find(pat).getScore()"?
What I note is that 676x(1-0.005)=672.62 and 41*(1-0.005)=40.795, so to me it looks like Sikulix is doing one downscaling of the search pattern object by the factor 0.005, does a first search, then replaces the region to search in with that smaller-now pattern, and, bum, it fails the next .find() because of "image to search (676, 41) is larger than image to search in (672, 40)". 


Could could you maybe try, 2 minutes, to replicate the issue with my code? Freshly I just took a Windows Desktop icons snapshot pattern and I ran the three .find()s one-by-one:

pat = Pattern("1608930740607.png") # a 153x92 search pattern
pat.similar(0.1) # to avoid any FindFaileds

pat.resize(1)
mat = SCREEN.find(pat)
print(mat.getScore()) # gives 0.99999922514, OK

pat.resize(0.99)
mat = SCREEN.find(pat)
print(mat.getScore()) # gives 0.906620442867, OK

pat.resize(0.98)
mat = SCREEN.find(pat)
print(mat.getScore()) # gives exception below

[error] JythonRunner: runPython: (
pat.resize(0.98)
mat = SCREEN.find(pat)
print(mat.getScore()) # gives exception below
) raised: Traceback (most recent call last):
  File "<string>", line 2, in <module>
	at org.sikuli.script.Finder$FindInput2.isValid(Finder.java:1244)
	at org.sikuli.script.Finder$Finder2.doFind(Finder.java:616)
	at org.sikuli.script.Finder$Finder2.find(Finder.java:582)
	at org.sikuli.script.Finder.find(Finder.java:195)
	at org.sikuli.script.Region.doCheckLastSeenAndCreateFinder(Region.java:2832)
	at org.sikuli.script.Region.checkLastSeenAndCreateFinder(Region.java:2802)
	at org.sikuli.script.Region.doFind(Region.java:2749)
	at org.sikuli.script.Region.find(Region.java:2271)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
org.sikuli.script.SikuliXception: org.sikuli.script.SikuliXcep
tion: image to search (153, 92) is larger than image to search in (151, 91)


Then I closed and restarted the SikuliX IDE, and run the whole "program" in one go. Returns:

0.99999922514
0.906620442867
[error] script [ DesktopTest ] stopped with error in line 13
[error] org.sikuli.script.SikuliXception ( org.sikuli.script.SikuliXception: image to search (153, 92) is larger than image to search in (151, 91) )
[error] --- Traceback --- error source first
line: module ( function ) statement 
13: main (  <module> )     mat = SCREEN.find(pat)
[error] --- Traceback --- end --------------


Oh, and when I use the replacement values (1, 1.1, 1.15) for upscaling of the pattern it works fine!!!
0.999999642372
0.586187005043
0.514091551304

What am I doing wrong?


Frohes Fest!
Simon

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.