模板匹配和更新

时间:2018-11-21 11:24:06

标签: matlab template-matching

我需要有关脚本的帮助,我试图找到一种更新模板尺寸的方法。 首次定义模板后,脚本将在每个连续的帧中将模板与搜索窗口相关联,如果最大相关性在某个范围内,则将使用最大相关性点的坐标为中心来更新模板。问题在于入侵者更改大小时,如何允许脚本跟随入侵者的大小?

以下是代码部分:

...                
[TWr TWc] = size(templatewindow);
[Tr Tc] = size(template);
corr_temp = normxcorr2(template,templatewindow);
corr_temp = imcrop(corr_temp,[Tc Tr TWc TWr]);
max_corr_temp(i) = max(max(corr_temp));
[tr tc tv] = find(corr_temp == max(max(corr_temp)));
if  (max_corr_temp(i) < 0.80) && (max_corr_temp(i) > 0.725)
lim_r = tr+Tr;
lim_c = tc+Tc;
nometemplate=['template',num2str(i_firm)];
    if lim_r > TWr
        lim_r = TWr;
    end
    if lim_c> TWc
        lim_c = TWc;
    end
    template = templatewindow(tr:lim_r,tc:lim_c);
    assignin('base',(nometemplate),template);
...

通过这种方式,模板的尺寸不会跟随入侵者的尺寸。有什么建议吗?

0 个答案:

没有答案