Ask Your Question

Revision history [back]

What's the best way for template matching with a mask?

Hello,

Im trying to template match some UI components in a game (e.g. detect if the UI component is there, and where).
I've looked into template matching and the way proposed here is pretty good, so using TM_CCOEFF_NORMED and treshhold the maximum value.
However this doesn't allow masking, which is pretty bad considering whats actually in the UI element is often variable. The problem is, the only normed method that works with masks is CV_TM_CCORR_NORMED which is... uh... pretty bad.

Now the workaround I've found for now is feature matching the template and comparing the matches with the spot found by template matching. This resolves the issue to see if the template is actually on screen, but doesn't do anything against miscalculation from CV_TM_CCORR_NORMED which can happen sometimes depending on the environment.

Is there a better way for all this?