Page 1 of 1

Template Matching - Implementation

Posted: Wed Mar 25, 2020 11:51 pm
by redcrow
Is the below still the case...Was wondering if the template matching can handle rotation or scale changes at all? (Was it improved to use a rolling integral image window?)

Template matching using something called an "integral image" to work.
Template matching works by having the camera look a like 32x32 image to find out of
a larger image (e.g. 320x240). That said, template matching doesn't handle rotation
or scale changes at all. It just slides around the image you want to find on the
large image and then returns the point of best match. This means its very fragile.
This requires 4 bytes per pixel in the big image. So, 307200 bytes... plus the size
of the image itself which is 320x240x2 = 153600 bytes.
So, that's 460800 in total. The M7 has about 350KB to play with.
We can improve template matching in the future using a rolling integral image window
which will fix this problem.
However, doing template matching in general requires a lot of CPU.

Thanks in Advance!

Re: Template Matching - Implementation

Posted: Thu Mar 26, 2020 10:37 am
by kwagyeman
Hi, template matching hasn't been worked on in a while. It could use a lot of improvements. The code isn't a lot and we have a performance optimizer on staff right now.

I'm doing OpenMV IDE updates currently... but, if you place a feature request to improve template matching on the forums we can optimize this method next.

Rotation and scale matching is really CPU intensive right now however. That said, using the log polar transforms might help optimize things.

(Rotation and scale require checking the whole image again at a different scale. Rotation the same way. With log polar it's possible to remap the image so that rotation matching is cheap).

Re: Template Matching - Implementation

Posted: Thu Mar 26, 2020 2:11 pm
by redcrow
Where does one make a feature request?

Regards

Re: Template Matching - Implementation

Posted: Thu Mar 26, 2020 5:00 pm
by kwagyeman
https://github.com/openmv/openmv/issues

This helps us track stuff. That said, it can literally sit there forever unless you bug me to do it repeatedly. I'm basically a fire fighter. No squeaking, no oil ;)

Re: Template Matching - Implementation

Posted: Thu Mar 26, 2020 7:10 pm
by redcrow
I opened up issue 744. https://github.com/openmv/openmv/issues/744

Thanks in advance!

Re: Template Matching - Implementation

Posted: Thu Mar 26, 2020 7:36 pm
by kwagyeman
Super. That said, I can't say when I will get to it.