警告:将非浮点数据转换为单个
Warning: Converting non-floating point data to single
我一直在研究特征提取和对极几何。但是,我经常遇到以下错误:
Warning: Converting non-floating point data to single.
In pdist2 (line 219)
In extractFeaturesU (line 93)
返回警告消息的代码行是:
[distance, position] = sort(pdist2(double(repmat(featuresA, size(xPoints, 1))), featuresB), 2, 'ascend');
下面显示了包含上述行的代码部分。
%% extract features
corresponding = [];
rightBound = size(sharpImageB, 2);
xPoints = 3 : 3 : rightBound - 3;
for index = 1 : size(realWantedPoints, 2)
%extract features from wanted points
disp('extracting features from wanted points...');
if strcmp(desc, 'hog')
[featuresA, pointsA] = extractHOGFeatures(sharpImageA, realWantedPoints(:, index)', ...
'CellSize', [8 8], 'BlockSize', [2 2], 'NumBins', 9, 'UseSignedOrientation', true);
elseif strcmp(desc, 'block')
[featuresA, pointsA] = extractFeatures(sharpImageA, realWantedPoints(:, index)', ...
'Method', 'Block', 'BlockSize', 21, 'Upright', true);
elseif strcmp(desc, 'surf')
[featuresA, pointsA] = extractFeatures(sharpImageA, realWantedPoints(:, index)', ...
'Method', 'SURF', 'SURFSize', 64, 'Upright', true);
end
% generate epipolar line points
liner = star([1 0 0]) * [realWantedPoints(:, index); 1];
yPoints = -(liner(3) + (liner(1) * xPoints)) / liner(2);
matrixB = [xPoints', yPoints'];
% extract features from epipolar line points
disp('extracting features from epipolar line points...');
if strcmp('hog', desc)
[featuresB, pointsB] = extractHOGFeatures(sharpImageB, matrixB, ...
'CellSize', [8 8], 'BlockSize', [2 2], 'NumBins', 9, 'UseSignedOrientation', true);
elseif strcmp('block', desc)
[featuresB, pointsB] = extractFeatures(sharpImageB, matrixB, ...
'Method', 'Block', 'BlockSize', 21, 'Upright', true);
elseif strcmp('surf', desc)
[featuresB, pointsB] = extractFeatures(greyB, matrixB, ...
'Method', 'SURF', 'SURFSize', 64, 'Upright', true);
end
% calculate similarity
[distance, position] = sort(pdist2(double(repmat(featuresA, size(xPoints, 1))), featuresB), 2, 'ascend');
corresponding = [corresponding; pointsB(position(1), :)];
end
xB = corresponding(:, 1);
yB = corresponding(:, 2);
我可以通过对两个变量调用 pdist2
来生成该错误:一个是 double 类型,另一个是 single 类型。例如
x = ones(5,1,'single');
y = ones(5,1,'double');
pdist2(x,y);
我猜你的 featuresB
变量是单精度浮点数,因此与你给 pdist2 的第一个参数的类型不匹配(它是双精度的,因为你明确地转换了它)。
我一直在研究特征提取和对极几何。但是,我经常遇到以下错误:
Warning: Converting non-floating point data to single. In pdist2 (line 219) In extractFeaturesU (line 93)
返回警告消息的代码行是:
[distance, position] = sort(pdist2(double(repmat(featuresA, size(xPoints, 1))), featuresB), 2, 'ascend');
下面显示了包含上述行的代码部分。
%% extract features
corresponding = [];
rightBound = size(sharpImageB, 2);
xPoints = 3 : 3 : rightBound - 3;
for index = 1 : size(realWantedPoints, 2)
%extract features from wanted points
disp('extracting features from wanted points...');
if strcmp(desc, 'hog')
[featuresA, pointsA] = extractHOGFeatures(sharpImageA, realWantedPoints(:, index)', ...
'CellSize', [8 8], 'BlockSize', [2 2], 'NumBins', 9, 'UseSignedOrientation', true);
elseif strcmp(desc, 'block')
[featuresA, pointsA] = extractFeatures(sharpImageA, realWantedPoints(:, index)', ...
'Method', 'Block', 'BlockSize', 21, 'Upright', true);
elseif strcmp(desc, 'surf')
[featuresA, pointsA] = extractFeatures(sharpImageA, realWantedPoints(:, index)', ...
'Method', 'SURF', 'SURFSize', 64, 'Upright', true);
end
% generate epipolar line points
liner = star([1 0 0]) * [realWantedPoints(:, index); 1];
yPoints = -(liner(3) + (liner(1) * xPoints)) / liner(2);
matrixB = [xPoints', yPoints'];
% extract features from epipolar line points
disp('extracting features from epipolar line points...');
if strcmp('hog', desc)
[featuresB, pointsB] = extractHOGFeatures(sharpImageB, matrixB, ...
'CellSize', [8 8], 'BlockSize', [2 2], 'NumBins', 9, 'UseSignedOrientation', true);
elseif strcmp('block', desc)
[featuresB, pointsB] = extractFeatures(sharpImageB, matrixB, ...
'Method', 'Block', 'BlockSize', 21, 'Upright', true);
elseif strcmp('surf', desc)
[featuresB, pointsB] = extractFeatures(greyB, matrixB, ...
'Method', 'SURF', 'SURFSize', 64, 'Upright', true);
end
% calculate similarity
[distance, position] = sort(pdist2(double(repmat(featuresA, size(xPoints, 1))), featuresB), 2, 'ascend');
corresponding = [corresponding; pointsB(position(1), :)];
end
xB = corresponding(:, 1);
yB = corresponding(:, 2);
我可以通过对两个变量调用 pdist2
来生成该错误:一个是 double 类型,另一个是 single 类型。例如
x = ones(5,1,'single');
y = ones(5,1,'double');
pdist2(x,y);
我猜你的 featuresB
变量是单精度浮点数,因此与你给 pdist2 的第一个参数的类型不匹配(它是双精度的,因为你明确地转换了它)。