c# - OpenCV MatchTemplate on GPU -
in c# project need fast template matching algorithm. have opencv implementation. simplified code is:
using opencvsharp; using opencvsharp.cplusplus; // ... var image = new mat("image.png"); var template = new mat("template.png"); double minval, maxval; point minloc, maxloc; var result = image.matchtemplate(template, matchtemplatemethod.ccoeffnormed); result.minmaxloc(out minval, out maxval, out minloc, out maxloc); console.writeline("maxloc: {0}, maxval: {1}", maxloc, maxval);
i'd same calculations on gpu speed them significantly, cannot find example of how that. example on github commented out , doesn't seem working.
i've attempted port opencv's matchtemplate()
function gpu before.
they give equations in their documentation method. called "normalized cross-correlation."
the naive approach port gpu (i did pixel shader). turned out slower opencv's cpu method. why? using method called "fast normalized cross-correlation" outlined in this paper j.p lewis ilm.
the trick correlation in frequency domain , take advantage of convolution theorem: point-wise multiplication in frequency domain equivalent convolution in spatial domain. means time complexity reduced, , have add fft.
Comments
Post a Comment