[1.1.2] findAnyList(): possible to find all matches? --- no, workaround

Asked by Ken Chen

------------------ workaround

--1: loop around a Finder::findAll()
finder = Finder(capture(aRegion))
patterns = [pat1, pat2, pat3]
matches = []
for pat in patterns:
    matches.append(finder.findAll(pat))
for match in matches:
    # evaluate the returned matches

--2; distribute the single findAlll() to threads
# select a threading feature

baseImage = capture(aRegion)

# per thread do this:
finder = Finder(baseImage) # Finder is not thread safe
matches = finder.findAll(pat))
# return some result

# in each thread do nothing else but findAll()

------------------------------------------------------------------------------------------------
Hi,

I read document below and know that findAnyList() returns match list of given patterns.

http://sikulix-2014.readthedocs.io/en/latest/region.html#find-more-than-one-image-in-a-region-at-the-same-time

However, returned match list seems provide only best match of each pattern. Is there any way to get 'all' matches of given patterns? For example, if there are 2 matches with img0, 1 match with img2 and 1 match with img3, findAnyList() returns 3 best matches only.

images = [img0, img1, img2, img3]
matches = findAnyList(images)
for match in matches:
    print match.getIndex(), match.getScore(), match.toStringShort()

# prints out something like:
0 0.999999761581 M[137,46 136x28]@S(0)
2 0.999999761581 M[368,99 124x27]@S(0)
3 0.999994277954 M[489,72 220x29]@S(0)

I would like to know if there have any API that can return 4 matches like below:
0 0.999999761581 M[137,46 136x28]@S(0)
0 0.999999666666 M[237,56 136x28]@S(0) // <-- just an example
2 0.999999761581 M[368,99 124x27]@S(0)
3 0.999994277954 M[489,72 220x29]@S(0)

Currently, I do it by findAll() API, and then loop it on each patterns. But is not so efficient.

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

I will not add this to version 1.1.x

In version 2 will be a feature to run any group of find ops against 1 screenshot in parallel.

You have to live with the workaround (see updated question)

Revision history for this message
Ken Chen (csimccw) said :
#2

Thanks RaiMan, that solved my question.