我正在创建以Matlab示例为蓝本的立体图像处理项目。来自其中一个的复制粘贴代码效果不佳。
I1 = rgb2gray(imread('viprectification_deskLeft.png'));
I2 = rgb2gray(imread('viprectification_deskRight.png'));
points1 = detectHarrisFeatures(I1);
points2 = detectHarrisFeatures(I2);
[features1, valid_points1] = extractFeatures(I1, points1);
[features2, valid_points2] = extractFeatures(I2, points2);
indexPairs = matchFeatures(features1, features2);
matchedPoints1 = valid_points1(indexPairs(:, 1),:);
matchedPoints2 = valid_points2(indexPairs(:, 2),:);
figure; showMatchedFeatures(I1, I2, matchedPoints1, matchedPoints2);
load stereoPointPairs
[fLMedS, inliers] = estimateFundamentalMatrix(matchedPoints1,matchedPoints2,'NumTrials',4000);
figure;
subplot(121); imshow(I1);
title('Inliers and Epipolar Lines in First Image'); hold on;
plot(matchedPoints1(inliers,1), matchedPoints1(inliers,2), 'go');
错误:
使用epilineTest时出错(第24行)索引操作无效。
祝你好运
答案 0 :(得分:0)
看起来你有一个旧版本的MATLAB。试着这样做:
[fLMedS, inliers] = estimateFundamentalMatrix(...
matchedPoints1.Location, matchedPoints2.Location,'NumTrials',4000);
通常,请查看您自己的本地MATLAB文档中的示例,而不是网站上的示例。该网站拥有最新版本的文档(目前为R2014a),示例可能使用旧版本中不存在的新功能。