"First find" orientation

Asked by Peter Attardo

When defining a region with multiple instances of the same match, the "first found" appears to be the one closest to the top. I searched around and can't find much documentation on how Sikuli determines what the first object is or how to change it. Is there any way to force Sikuli to start its search from the bottom of the region? Or otherwise gain more control of the orientation or direction of the search?

Thanks,
Peter

Question information

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

The Sikuli find feature strictly uses the similarity score, to decide internally which of more than one matches in the given region is returned.
Since the internally used OpenCV templateMatch feature scans the region from top left to bottom right (no way to change that at the function level, one would have to invert the pixel matrices before), it is rather likely, that you get a match near the top left (not necessarily the first possible from your guessing).
You can use Region.findAll(), to get all matches in the region and sort the resulting list with any aspect you want (see docs).

Revision history for this message
Peter Attardo (kzqdnsw4i20a5pz947yg-peter-x8oxkp4um1x7tvxk19ia) said :
#2

Thanks for the answer!

Unrelated, but my script continues to run even after pressing cmd+shift+c. The IDE pops back up, and the Run > Stop option is greyed out, so it seems like it should be stopped, but it keeps capturing the mouse and logging. Am I doing something wrong or is this a known bug?

Revision history for this message
Peter Attardo (kzqdnsw4i20a5pz947yg-peter-x8oxkp4um1x7tvxk19ia) said :
#3

Thanks RaiMan, that solved my question.

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

Are you using the IDE's unittest feature?

If yes, see faq 1804.

If not, come back with more info.

Revision history for this message
Peter Attardo (kzqdnsw4i20a5pz947yg-peter-x8oxkp4um1x7tvxk19ia) said :
#5

It was occurring due to an infinite while loop. I still don't know how to break the loop using cmd+shift+c, but it was easy enough to rewrite the code to avoid the loop.