Is non-rectangular matching possible?

Asked by Laurent Vaucher

I would like to find on screen an image that does not have rectangular bounds. For instance, I want to look for a round button and I only care for the button, not its surroundings. It might be placed on different backgrounds that I don't know in advance.
I thought I could build a Pattern from a PNG with transparency to mean: "I'm not interested in the comparison of transparent pixels", but it does not seem to work like that. I generally don't find any match over the standard 0.7 threshold.

Is there any other way?

Thanks.

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

Allowing patterns with transparency to ignore parts of the image is not a feature yet (but already a request bug).

The only possibility is to make the captured rectangle so that is contains as little of the background (less than 20% of the whole area) as possible.

To be sure you found the right match, you might want to restrict the region to the area, where your searched image should most probably be.

A bit tricky, but usually it is possible to find a setup of the form

reg.find(Pattern(<some-mostly-unique-image.png>).similar(0.95)

where the 3 parts (reg, some-mostly-unique-image.png and the similarity) have to be optimized for a reliable result.

Revision history for this message
Laurent Vaucher (laurent-vaucher) said :
#2

Thanks RaiMan, that solved my question.