使用estimateFundamentalMatrix时出错期望的matched_points1是以下类型之一:numeric

时间:2014-04-26 01:19:20

标签: matlab matching feature-detection feature-extraction matlab-cvst

我按照这个页面(http://www.mathworks.cn/cn/help/vision/ug/stereo-image-rectification.html)并使用了estimateFundamentalMatrix函数来计算基本矩阵,但我从MATLAB命令窗口收到一条错误消息说:

Error using estimateFundamentalMatrix
Expected matched_points1 to be one of these types:

numeric

我的代码:

img1 = rgb2gray(imread('37_1.jpg'));
img2 = rgb2gray(imread('38_1.jpg'));

img1=im2double(img1);
img2=im2double(img2);

points1 = detectSURFFeatures(img1,'MetricThreshold', 2000);
points2 = detectSURFFeatures(img2,'MetricThreshold', 2000);

[featurePoint1, validPoint1] = extractFeatures(img1, points1);
[featurePoint2, validPoint2] = extractFeatures(img2, points2);

indexPairs = matchFeatures(featurePoint1, featurePoint2, 'Metric', 'SAD', 'MatchThreshold', 5);
matchedPoints1 = validPoint1(indexPairs(:, 1),:);
matchedPoints2 = validPoint2(indexPairs(:, 2),:);

[fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(matchedPoints1, ...
matchedPoints2, 'Method', 'RANSAC', 'NumTrials', 10000, 'DistanceThreshold', ...
0.1, 'Confidence', 99.99);

我的编程环境是Win7 plus MATLAB R2012b。

1 个答案:

答案 0 :(得分:1)

我收到上述错误消息的原因是因为该页面是针对R2014a的,但我的MATLAB是R2012b,所以这是一个版本问题。我们只需要像这样更改代码:

[fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(matchedPoints1.Location, ...
matchedPoints2.Location, 'Method', 'RANSAC', 'NumTrials', 10000, 'DistanceThreshold', ...
0.1, 'Confidence', 99.99);