Template Matching - Implementation

Discussion related to "under the hood" OpenMV topics.
redcrow
Posts: 10
Joined: Wed Jul 17, 2019 7:28 pm

Template Matching - Implementation

Postby redcrow » Wed Mar 25, 2020 11:51 pm

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!
User avatar
kwagyeman
Posts: 3832
Joined: Sun May 24, 2015 2:10 pm

Re: Template Matching - Implementation

Postby kwagyeman » Thu Mar 26, 2020 10:37 am

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).
Nyamekye,
redcrow
Posts: 10
Joined: Wed Jul 17, 2019 7:28 pm

Re: Template Matching - Implementation

Postby redcrow » Thu Mar 26, 2020 2:11 pm

Where does one make a feature request?

Regards
User avatar
kwagyeman
Posts: 3832
Joined: Sun May 24, 2015 2:10 pm

Re: Template Matching - Implementation

Postby kwagyeman » Thu Mar 26, 2020 5:00 pm

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 ;)
Nyamekye,
redcrow
Posts: 10
Joined: Wed Jul 17, 2019 7:28 pm

Re: Template Matching - Implementation

Postby redcrow » Thu Mar 26, 2020 7:10 pm

I opened up issue 744. https://github.com/openmv/openmv/issues/744

Thanks in advance!
User avatar
kwagyeman
Posts: 3832
Joined: Sun May 24, 2015 2:10 pm

Re: Template Matching - Implementation

Postby kwagyeman » Thu Mar 26, 2020 7:36 pm

Super. That said, I can't say when I will get to it.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: MSN [Bot] and 5 guests