Find multiple items on the same "screen sample" --- feature in 1.1.2+

Asked by GZ on 2017-12-07

------------------------ see related bug 1736968

Hi Everyone,

I'm trying to figure out how I could make Sikuli check the same "screengrab" or "sample of screen" multiple times.
And I'm not talking about the image inside the find() command, I'm talking about when Sikuli is looking at the screen to find things.

I want to be able to get a screen "sample" and let Sikuli find multiple things in that one sample.
With rapidly changing information this is the only way I could sample the screen once and then let Sikuli find multiple things, then sample again, let it find multiple things, etc. etc.

Is this possible?

I was thinking something like this?
sample("temp.png")
exists(Pattern("thing01.png").exact(), 0, "temp.png")
exists(Pattern("thing02.png").exact(), 0, "temp.png")

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
GZ
Solved:
9 hours ago
Last query:
9 hours ago
Last reply:
12 hours ago
GZ (george-zador) said : #1

Or is it possible to execute exists() commands at the exact same time?

masuo (masuo-ohara) said : #2

Please consider whether Finder object can be used.
http://sikulix-2014.readthedocs.io/en/latest/finder.html?#finder

GZ (george-zador) said : #3

Hi masuo.
If I understand the correctly how the Finder works, it would need a pre-saved screenshot, which will not work in my case.
I want to get the screen sample on-the-fly and release it once I'm done checking different things in it. Then later I repeat this process again and again.

RaiMan (raimund-hocke) said : #4

If you can wait a few hours:
This feature is principally available in 1.1.2, but the aspect you need has still to be baked into a method.
And I want the feature to be doc'ed.

I am just starting to do the work.

I will give you a note, when it is ready later.

behind the scenes:
Against one screenshot a list of images/patterns is checked concurrently (threading) and a corresponding list of matches is returned.

matches = findAny(img1, img2, pattern1, ...)

If an image/pattern was found, the corresponding list entry in the result matches contained the Match otherwise null/None.

The rest pre- and post-processing would be your job.

But if you do not trust me :-)
as masuo mentioned in comment #2 you can build your own solution (a function with about 50 lines of code)
- take a screenshot
- setup a Finder
- distribute the needed Finder.find's into different threaded function calls.
- collect the returned matches and process them

GZ (george-zador) said : #5

Hi RaiMan, that sounds great, thank you very much! :)

I will have a play with the Finder method and when the new feature in 1.1.2 is done I will use that.

Thanks again!

GZ (george-zador) said : #6

Thanks RaiMan, that solved my question.

RaiMan (raimund-hocke) said : #7

The implementation is ready for use in the latest nightly build (#86)
docs: http://sikulix-2014.readthedocs.io/en/latest/region.html#find-more-than-one-image-in-a-region-at-the-same-time

GZ (george-zador) said : #8

Fantastic! Thanks very much RaiMan!