Ask Your Question
1

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

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

gabrielpasv gravatar image

updated 2020-11-02 17:13:28 -0600

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

Comments

1

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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

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

Witek gravatar image

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

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: http://opencv-code.com/tutorials/fast-template-matching-with-image-pyramid/ 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

Question Tools

Stats

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

Seen: 4,567 times

Last updated: May 21 '14