2015-12-08 168 views
1

我写了下面的函数来执行图像校正。我正在使用标准的MATLAB库函数(estimateUncalibratedRectificationestimateFundamentalMatrix)以及我自己的包装函数,以便MATLAB的matchFeatures执行立体声校正。然而,与相同的输入我每次都得到不同的结果。我知道这与使用RANSAC来估计基本矩阵有关。然而,整改有时是可怕的,其他人也可以通过。例如,在10个不同的我用相同的输入功能的运行,两种结果都没事,而8给了我这个错误变化:MATLAB估计未经校准的校准非确定性行为

Warning: An epipole may be located inside of an image. The epipoles 
are located at [285.8503,76.1656] in I1 and [265.5734,130.3931] in I2, 
but the specified imageSize was [320,568]. Severe distortion may 
result if T1 or T2 are used to transform these images. See 
isEpipoleInImage for more information. 
> In coder.internal.warning (line 7) 
    In cvalgEstimateUncalibratedRectification (line 114) 
    In estimateUncalibratedRectification (line 107) 
    In pairwiseTransformation (line 48) 

我认为,这意味着整改无法投射核点到无穷。

这是怎么回事?值得注意的是,我的图片之间有279条推测匹配和32条inlierMatch。

我的功能:

function [t1, t2] = pairwiseTransformation(img1, img2, features1, features2) 

    % Identify putative matches 
    [matches1, matches2] = matchFeaturePoints(rgb2gray(img1), features1, ... 
     rgb2gray(img2), features2); 

    % Estimate the fundamental matrix so that matches2' * F * matches1 = 0 
    % F transforms matches1 to a line that runs through the corresponding 
    % point in matches1. Therefore, any rotation and translation derived from F 
    % (and E) will apply to camera 2's relative position, holding camera 1 fixed. 
    [F, inliers] = estimateFundamentalMatrix(matches1, matches2, 'Method', 'RANSAC', ... 
     'NumTrials', 2000, 'DistanceThreshold', 1e-4); 

    % Use the RANSAC inliers to determine the relative position of img2 compared to img1 
    inlierMatches1 = matches1(inliers, :); 
    inlierMatches2 = matches2(inliers, :); 


    [t1, t2] = estimateUncalibratedRectification(F, inlierMatches1, inlierMatches2, ... 
     size(img1)); 

    r1 = imwarp(img1, projective2d(t1), 'OutputView', imref2d(size(img1))); 
    r2 = imwarp(img2, projective2d(t2), 'OutputView', imref2d(size(img1))); 

    figure; 
    subplot(2,2,1),imshow(img1) 
    subplot(2,2,2),imshow(img2) 
    subplot(2,2,3),imshow(r1) 
    subplot(2,2,4),imshow(r2) 
end 

这里有一个体面的整流(顶行的原始图像,底部整流):

Good

及这里的给了极点警告完全拙劣的努力:

Bad

+0

再看一下,我猜测这个拙劣的努力已经被纠正,只是结果是废话。 – marcman

回答

0

32场比赛中的比赛似乎太少......你假定的比赛看起来如何?

有一点要尝试的是调整estimateFundamentalMatrix的参数。我会使用MSAC而不是RANSAC,并将DistanceThreshold增加到.1甚至1等。同时,您可能需要增加Confidence参数,可能为99.99。这将迫使RANSAC进行更多的试验,并增加找到正确解决方案的机会。

另一个要尝试的是从matchFeatures获得更多更好的假定匹配。您应该尝试调整特征检测器功能的参数以获取更多功能,然后调整matchFeatures的参数以确保匹配仍然良好。你也可以尝试不同的探测器和描述符。