0

我想从以下 Matlab 函数(Harris 角检测)生成 C++ 代码,该函数从图像中检测角。我的约束是我必须在没有可变大小支持的 C++ 中生成静态库。因此,我从设置中禁用了可变大小支持,并且还选择了目标平台作为未指定的 32 位处理器。通过这种方式,我将能够在 Vivado HLS 中将其用于 FPGA 项目。

但是,当我生成代码时,包含ordfilt2函数的行会抛出一个错误,即FIND requires variable sizing

如果有解决此问题的方法,请帮助我。我在这里看到了类似的问题Matlab error "Find requires variable sizing"。但我不确定这如何适用于我的情况。谢谢。

这是代码:

function [cim] = harris(im , thresh)

dx = [-1 0 1; -1 0 1; -1 0 1]; % Derivative masks
dy = dx';

Ix = conv2(im, dx, 'same');    % Image derivatives
Iy = conv2(im, dy, 'same');    

% Generate Gaussian filter of size 6*sigma (+/- 3sigma) and of
% minimum size 1x1.
sigma = 1.5;
g = fspecial('gaussian',max(1,fix(6*sigma)), sigma);

Ix2 = conv2(Ix.^2, g, 'same'); % Smoothed squared image derivatives
Iy2 = conv2(Iy.^2, g, 'same');
Ixy = conv2(Ix.*Iy, g, 'same');

cim = (Ix2.*Iy2 - Ixy.^2)./(Ix2 + Iy2 + eps); % Harris corner measure

% Extract local maxima by performing a grey scale morphological
% dilation and then finding points in the corner strength image that
% match the dilated image and are also greater than the threshold.

radius = 1.5;
sze = 2*radius+1;                   % Size of mask.


mx = ordfilt2(cim,sze^2,ones(sze)); % Grey-scale dilate.

cim = (cim==mx)&(cim>thresh);       % Find maxima.


end

这是错误

4

0 回答 0