立体图像的图像校正

Image Rectification of Stereo Images

我的最终目标是做视觉里程计。为此,我将收集自己的图像数据集。但首先,我正在尝试使用 Malaga Dataset . The dataset is stereo images dataset. I already downloaded the malaga-urban-dataset-extract-07.zip file and I tryed to do image rectification with raw images. I used the MATLAB code 的原始图像进行图像校正:

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数据集的原始校正图像不相似。例如;给大家分别展示一下Malaga Raw Image Dataset的第20帧,我用的Matlab代码的整改结果和Malaga Dataset整改后的原图:

我知道我使用了未标定相机的Matlab校正代码。但是,它已经是马拉加数据集中校准的原始图像数据集。另一个整改 matlab 代码是 this But the Malaga dataset images (or the dataset that I will collect) doesn't contain the Checker board in it. So, I couldn't understand that how can i use this 包含不包含棋盘的图像的代码。

我有三个问题:

  1. 如何解决我上面写的错误问题?
  2. 为什么Matlab校正后的结果和校正后的原图不一样?
  3. 如何用其他方式校正原始图像?

差异很可能是因为您使用了 estimateUncalibratedRectification() 而 Malaga 数据集的校正图像依赖于使用校准参数进行适当的校正。

Malaga dataset webpage, you can find the stereo calibration parameters (e.g. http://ingmec.ual.es/~jlblanco/malaga-urban-dataset/calibration/camera_params_rectified_a=0_800x600.txt.

使用这种方法,您应该会得到相同的结果。