[Project] Fast and rotation invariant template matching

Lots of people have complained about cv::matchTemplate () because it is not a rotation invariant function, which means it is not practical.

Therefore, I improved and combined this function with a search strategy, and create a project.Also, this project passed some cases in real world assembly lines.

Details and the source code of this project

The formula of similarity is as followed:

Some practical tests:



It can also used as OCR

If you think my project useful and practical, give me a star on github

Current Status:
I am doing researching on scale invariant version, perhaps next month can get a positive result.
If you have any test data that can verify scale issue, please contact me.

what does the code even do with the pyramid?

all I can tell from the code is that it tries matchTemplate on a number of rotated versions of the template. that shouldn’t be fast at all, considering a single matchTemplate call on any usefully large image takes a while.

and please stop posting that stuff to every thread you can find.

  1. what does the code even do with the pyramid?
    speed up the whole process by reducing possible searching area

  2. on a number of rotated versions of the template. not the rotated templates but the rotated source, which is the key element of this method

  3. that shouldn’t be fast at all, considering a single matchTemplate call on any usefully large image takes a while.
    I just don’t get it. I made some tests in comparison with commercial image processing libraries, and the results demonstrated its speed.
    Of course, this method will become slow when image size increases

  4. stop posting
    OK

how hard would it be, to seperate the algorithm from the gui app ?
as it is now, only VS users can even build it

  1. separating from gui is easy.
    only the part of showing results will be affected

  2. vector can be replaced with some containers in other language

  3. Uncertainty: direct access to Mat’s elements

1 Like

20220602 update:

Using SIMD version of image convolution to replace matchTemplate () with parameter CV_TM_CCORR

For many cases, it significantly speed up the process. (For small template, it is slight slow)
See this commit