我正在尝试运行,但在OCTAVE 中执行相同操作时我遇到 UNDEFINED错误。
我在下面附上了我的代码:
function [yIndex, xIndex] = template_match_2D(template, scene);
c =normxcorr2(template, scene);
[yRaw xRaw] = find(c == max(c(:)));
yIndex = yRaw - size(template, 1) + 1;
xIndex = xRaw - size(template, 2) + 1;
endfunction
pkg load image;
#Test
car = imread('car.png');
imshow(car);
tyre = car(200:250, 300:350);
imshow(tyre);
[y x] = template_match_2D(tyre, car);
disp([y x]);
以上代码在 OCTAVE 中返回以下错误:
template_match_2D
error: 'template' undefined near line 2 column 17
error: called from
template_match_2D at line 2 column 5
我该如何解决这个问题?