我的最终目标是进行视觉里程计。为此,我将收集我自己的图像数据集。但首先,我正在尝试使用Malaga Dataset的原始图像进行图像校正。数据集是立体图像数据集。我已经下载了 malaga-urban-dataset-extract-07.zip 文件,并尝试使用原始图像进行图像校正。我使用了MATLAB 代码:
path='C:\Users\Jasmine\Desktop\malaga_raw';
for i=0:2120
I1 = imread([path '\image_0\' sprintf('%06d.jpg',i)]); % left camera images
I2= imread([path '\image_1\' sprintf('%06d.jpg',i)]); % right camera images
I1gray = histeq(rgb2gray(I1));
I2gray = histeq(rgb2gray(I2));
blobs1 = detectSURFFeatures(I1gray, 'MetricThreshold', 2000);
blobs2 = detectSURFFeatures(I2gray, 'MetricThreshold', 2000);
[features1, validBlobs1] = extractFeatures(I1gray, blobs1);
[features2, validBlobs2] = extractFeatures(I2gray, blobs2);
indexPairs = matchFeatures(features1, features2, 'Metric', 'SAD', ...
'MatchThreshold', 5);
matchedPoints1 = validBlobs1(indexPairs(:,1),:);
matchedPoints2 = validBlobs2(indexPairs(:,2),:);
[fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(...
matchedPoints1, matchedPoints2, 'Method', 'RANSAC', ...
'NumTrials', 10000, 'DistanceThreshold', 0.1, 'Confidence', 99.99);
if status ~= 0 || isEpipoleInImage(fMatrix, size(I1)) ...
|| isEpipoleInImage(fMatrix', size(I2))
error(['Either not enough matching points were found or '...
'the epipoles are inside the images. You may need to '...
'inspect and improve the quality of detected features ',...
'and/or improve the quality of your images.']);
end
inlierPoints1 = matchedPoints1(epipolarInliers, :);
inlierPoints2 = matchedPoints2(epipolarInliers, :);
[t1, t2] = estimateUncalibratedRectification(fMatrix, ...
inlierPoints1.Location, inlierPoints2.Location, size(I2));
tform1 = projective2d(t1);
tform2 = projective2d(t2);
[I1Rect, I2Rect] = rectifyStereoImages(I1, I2, tform1, tform2, 'OutputView', 'Full');
folder = 'C:\Users\Jasmine\Desktop\malaga_raw';
newimagename_1 = [folder '\i_0\' sprintf('%06d.jpg',i)]; % left camera images
imwrite(I1Rect,newimagename_1)
newimagename_2 = [folder '\i_1\' sprintf('%06d.jpg',i)]; %right camera images
imwrite(I2Rect,newimagename_2)
end
但它给了我第 152 帧的错误:
if status ~= 0 || isEpipoleInImage(fMatrix, size(I1)) ...
|| isEpipoleInImage(fMatrix', size(I2))
error(['Either not enough matching points were found or '...
'the epipoles are inside the images. You may need to '...
'inspect and improve the quality of detected features ',...
'and/or improve the quality of your images.']);
end
除了这个错误之外,经过修正的图像(从第 1 帧到第 151 帧)已经与 Malaga 数据集的原始修正图像不相似。例如; 如果我分别给你看一下马拉加原始图像数据集的第20帧,我使用的Matlab代码的校正结果和马拉加数据集的原始校正图像:
我知道我对未校准的相机使用了 Matlab 纠正代码。但是,它已经是马拉加数据集中的校准原始图像数据集。另一个整改 matlab 代码是这个但是马拉加数据集图像(或我将收集的数据集)不包含棋盘。所以,我无法理解如何将此代码与不包含棋盘格的图像一起使用。
我有三个问题:
- 如何解决我在上面写的错误问题?
- 为什么 Matlab 校正的结果与原始校正图像不相似?
- 我怎样才能用另一种方式纠正原始图像?