[request] Find every match of multiple patterns (something like findAnyListAll())

Asked by Jaroslav Novotny

Hi, I can find the best matches from list of patterns using:
matches = region.findAnyList(list_of_patterns)

I can also find all matches of a single pattern in region using:
matches = region.getAll(pattern)

How do I find all matches of each item in list_of_patterns in one go? It's performance sensitive, I want to take single screen snippet and perform the searches in parallel.

Do I have to somehow code this more low-level-ish using Finder class on taken image from screen.capture(region)? This results in the image being saved to disc and then read back, which isn't the fastest. Is that what happens with region.find(pattern) internally too, does it go through temp storage?

Thanks a ton!

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1

Exactly "findAnyList" is able to do it that you want to do.

imagelist=["1593840754190.png","1593840763712.png","1593840771119.png"]
mm = findAnyList(imagelist)
for m in mm:
    m.highlight(1)

Revision history for this message
Jaroslav Novotny (jaroslav-novotny) said :
#2

Sadly that's no the case.

findAnyList performs find operation for each item of the list, which results in only the best match being found for each list item, but not all of them (not all of visible occurrences of that pattern). Same like region.find(pattern) finds only the best match.

Ideally I'd need something like a region.getAllList(list_of_patterns) function.

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

ok, understood and accepted.

What you want is a findAnyListAll(), that returns a list of match lists, where each match list has all matches as if a findAll() has been made for the respective pattern.

I accept this as a feature request.

As a workaround you might dispatch a findAllList() for each pattern to parallel threads.

Can you help with this problem?

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

To post a message you must log in.