I need to do template matching in 360 degrees.
Mostly template is 80*120 and image is 640*480 grayscale (8 bit).
For non-rotation I am using opencv cvmatchtemplate which is working pretty fine.
I tried rotating template at various angles and doing cvmatchtemplate, it’s working but consuming too much time.
For normal template match it is taking 12 ms, and for 360 degrees less than 50 ms is required.
Search in Google Scholar for “synthetic discriminant functions” or “composite correlation filters”. This is a good starting point: http://www.opticsinfobase.org/abstract.cfm?URI=ao-31-23-4773. If you can find the book “Correlation Pattern Recognition“, section 6.2 explains composite filters as well.
The main idea is that you take the templates generated by rotating your images and generate a single synthetic template. You do this by formulating a system of linear equations of the form
Where
Ais the coefficient matrix generated from the templates you have available.xis the synthetic template you’re going to determine, andcis a constraints vector. The constraints can be set to include some templates and to reject others.The problem is that when you combine too many templates into one you start loosing matching performance. There are, of course, ways to overcome this problem depending on what additional information you have available about the images in which you plan to use your synthetic templates.