Python Forum

Full Version: OpenCV - Distinguishing between three icons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have an application that needs to determine when a particular icon is showing:
X
[Image: JTwA9qE.png]

Lakitu
[Image: 9j85n84.png]

Mario
[Image: jHrz06q.png]

One icon will be showing at any given time, the background behind the icon will always be changing. They are displayed in the same location and switch between each other. I need to be able to determine when the icon is displaying the 'X'. Preferably using OpenCV. My current method is using inRange and defining a colour range, then if enough pixels fall within that colour range, I consider the X found. The issue is a lot of the Lakitu falls within the same colour range making it not reliable enough.

The other important point is that many people run this software, and every persons game capture and colours are slightly different so I have to make it lenient enough to work on slightly different colours.

One way I thought of was making it exclude colours from the mask if the green and blue value weren't within a defined range of each other, as the Lakitu doesn't really contain any blue, however the X always has similar blue and green components. I have no clue where to start though.

Thank you!
Hello,

If you have only three templates, you can use the template matching of OpenCV after get this three template in picture files:

https://docs.opencv.org/3.0-beta/doc/py_...ching.html
Thanks for the reply!

I just tried template matching, however I don't think it;s reliable enough for my needs. Especially as the quality of the X picture can vary a reasonable amount depending on the person using the program. At times depending on the background behind the X, it only gets me a 50% match, and that's using a template taken from my own video capture, so the results would be worse for someone with a different capture quality.