www.gusucode.com > vision 源码程序 matlab案例代码 > vision/ComputeFundamentalMatrixExample.m

    %% Compute Fundamental Matrix
% This example shows you how to compute the fundamental matrix. It uses 
% the least median of squares method to find the inliers.
%% 
% The points, matched_points1 and matched_points2, have been putatively
% matched.
load stereoPointPairs
[fLMedS,inliers] = estimateFundamentalMatrix(matchedPoints1,...
    matchedPoints2,'NumTrials',4000);
%% 
% Show the inliers in the first image.
I1 = imread('viprectification_deskLeft.png');
figure; 
subplot(121);
imshow(I1); 
title('Inliers and Epipolar Lines in First Image'); hold on;
plot(matchedPoints1(inliers,1),matchedPoints1(inliers,2),'go')
%% 
% Compute the epipolar lines in the first image.
epiLines = epipolarLine(fLMedS',matchedPoints2(inliers,:));
%% 
% Compute the intersection points of the lines and the image border.
points = lineToBorderPoints(epiLines,size(I1));
%% 
% Show the epipolar lines in the first image
line(points(:,[1,3])',points(:,[2,4])'); 
%% 
% Show the inliers in the second image.
I2 = imread('viprectification_deskRight.png');
subplot(122); 
imshow(I2);
title('Inliers and Epipolar Lines in Second Image'); hold on;
plot(matchedPoints2(inliers,1),matchedPoints2(inliers,2),'go')
%% 
% Compute and show the epipolar lines in the second image.
epiLines = epipolarLine(fLMedS,matchedPoints1(inliers,:));
points = lineToBorderPoints(epiLines,size(I2));
line(points(:,[1,3])',points(:,[2,4])');
truesize;