イメージからコーナーを検出する次の Matlab 関数 (Harris コーナー検出) から C++ コードを生成したいと考えています。そのため、設定から可変サイズのサポートを無効にし、ターゲット プラットフォームを未指定の 32 ビット プロセッサとして選択しました。このようにして、FPGA プロジェクトの Vivado HLS で使用できるようになります。
ただし、コードを生成すると、ordfilt2関数を含む行で、 FIND requires variable sizingというエラーがスローされます。
この問題の回避策がある場合は、助けてください。Matlab エラー "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