Ask Your Question

Multiple templates and one match. Using template Matching. How ?

asked 2014-05-21 06:21:31 -0500

gabrielpasv gravatar image

Hi Guys, I am new to openCV.

I need to use template Matching fuction of openCV and I need some help. I have a video stream and I want to compare each frame with several templates.

So I have a database of templates (about 4 or 5 images) that I need to use to find my ROI on the video stream. How is that can be done ? I google for it but I couldn't find anything with multiple templates. I found the opposite (find several matches with one template) but not finding one match with multiple templates.

edit retag flag offensive close merge delete



I don't see a way how to get around running matchTemplate for all your templates and hope it won't get too slow...

A faster not so accurate way would maybe to match the templates in alternating frames, e.g. match 1st template in 1st frame, 2nd in the 2nd frame, ... 5th in the 5th frame, then start again, 1st temmplate with the 6 frame, etc.

Guanta gravatar imageGuanta ( 2014-05-21 06:34:15 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-05-21 15:37:48 -0500

Witek gravatar image

updated 2014-05-21 15:39:48 -0500

I don't know if temple matching is the best solution, but if it works for you and you just want to speed up the process easily, use OpenMP and run template matching on separate cores. With contemporary processors you could match up to 8 templates at a time. You can also try to use fast template matching to speed things up: If you use both approaches at the same time you can expect a serious speed-up.

The best solution would be to optimize the template matching code to support multiple templates (I think it is planned in future releases), but it is not so easy to do.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2014-05-21 06:21:31 -0500

Seen: 3,869 times

Last updated: May 21 '14