当我比较两个不同的图像时,我收到以下错误。但是,如果我将图像与自身进行比较,代码就可以完美地运行。enter image description here
CODE:
a = imresize(imread('02.03.bmp'),300/300);
b = imresize(imread('02.04.bmp'),300/300);
% basmati, book, box, scene
detector = cv.FeatureDetector('BRISK');
extractor = cv.DescriptorExtractor('BRISK');
tic
keypoints1 = detector.detect(a);
descriptors1 = extractor.compute(a, keypoints1);
keypoints2 = detector.detect(b);
descriptors2 = extractor.compute(b, keypoints2);
toc
index_pairs = matchFeatures(descriptors1,descriptors2);
matchpoints1 = [];
matchpoints2 = [];
for i = index_pairs(:,1)'
matchpoints1 = [matchpoints1 keypoints1(i).pt'];
end
for i = index_pairs(:,2)'
matchpoints2 = [matchpoints2 keypoints2(i).pt'];
end
figure;
subplot(121);
imshow(a);
hold on; scatter(matchpoints1(1,:),matchpoints1(2,:),'yo','LineWidth',.5);
subplot(122);
imshow(b);
hold on; scatter(matchpoints2(1,:),matchpoints2(2,:),'yo','LineWidth',.5);
ERROR:
feature_extraction 经过的时间是0.290193秒。 特征提取 经过的时间是0.307123秒。 指数超过矩阵维度。
feature_extraction出错(第31行) 坚持,稍等;散射(matchpoints1(1,:),matchpoints1(2,:), '哟', '线宽',5);
答案 0 :(得分:0)
检查matchpoints1
的大小
看起来大小(matchpoints1,1)< 2