Undefined function 'showMatchedFeatures' for input arguments of type 'SURFPoints'.

4 views (last 30 days)
I'm trying to work on a project which is similar to that in the link below; as a first step i tried to make the exact thing as in the link http://www.mathworks.com/help/vision/gs/object-detection-and-tracking.html#btt5qyu , but when i compile the code i get this error
" Undefined function 'showMatchedFeatures' for input arguments of type 'SURFPoints'. Error in Compare (line 46) showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,... "
Compare is the name of my function. I dont know if my matlab version has something to do with this error i have matlab R2012a.
if true
function [ Image] = Compare( Img )
% Reading the reference Image
I= imread('C:\Users\user\Desktop\Matlab-Comparsion\2.jpg');
C=rgb2gray(I);
boxImage = C;
figure; imshow(boxImage);
title('Image of a Box');
%Reading the target image
II= imread('C:\Users\user\Desktop\Matlab-Comparsion\1.jpg');
CC=rgb2gray(II);
sceneImage = CC;
figure;
imshow(sceneImage);
title('Image of a Cluttered Scene');
%Detect feature images
boxPoints = detectSURFFeatures(boxImage);
scenePoints = detectSURFFeatures(sceneImage);
%Visualize the strongest feature points found in the reference image.
figure;
imshow(boxImage);
title('100 Strongest Feature Points from Box Image');
hold on;
plot(boxPoints.selectStrongest(100));
%Visualize the strongest feature points found in the target image.
figure;
imshow(sceneImage);
title('300 Strongest Feature Points from Scene Image');
hold on;
plot(scenePoints.selectStrongest(300));
%Extract feature descriptors at the interest points in both images.
[boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints);
[sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints);
%Match the features using their descriptors.
boxPairs = matchFeatures(boxFeatures, sceneFeatures);
%Display putatively matched features.
matchedBoxPoints = boxPoints(boxPairs(:, 1), :);
matchedScenePoints = scenePoints(boxPairs(:, 2), :);
figure;
title('Putatively Matched Points (Including Outliers)');
*%This is line 46 where the compiler is indicating an error*
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,...
matchedScenePoints,'montage');
%estimateGeometricTransform calculates the transformation relating the matched points,
%while eliminating outliers. This transformation allows us to localize the object in the scene.
[tform, inlierBoxPoints, inlierScenePoints] = estimateGeometricTransform(matchedBoxPoints, ...
matchedScenePoints, 'affine');
%Display the matching point pairs with the outliers removed
figure;
showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints,...
inlierScenePoints, 'montage');
title('Matched Points (Inliers Only)');
%Get the bounding polygon of the reference image.
boxPolygon = [1, 1;... % top-left
size(boxImage, 2), 1;... % top-right
size(boxImage, 2), size(boxImage, 1);... % bottom-right
1, size(boxImage, 1);... % bottom-left
1, 1]; % top-left again to close the polygon
% Transform the polygon into the coordinate system of the target image. The transformed polygon indicates the location of the object in the scene.
newBoxPolygon = transformPointsForward(tform, boxPolygon);
%Display the detected object.
figure();
imshow(sceneImage);
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');
end
end

Answers (4)

Dima Lisin
Dima Lisin on 2 May 2014
showMatchedFeatures() does not exist in 2012a. It was introduced in 2013a, if I remember correctly. You should be able to use a helper function cvexShowMatches() instead.
  2 Comments
fatin
fatin on 26 Nov 2014
i change it to cvexShowMatches() but it cannot work with 'montage', then how i want to correct it? TQ
Dima Lisin
Dima Lisin on 26 Nov 2014
You would have to write it yourself, using imshowpair and plot . You can plot the first set of points just by calling plot. Then to plot the second set of points, you would need to add the width of the first image to their x-coordinates, to get them to appear on the second image.

Sign in to comment.


Mystery Devil
Mystery Devil on 10 Feb 2018
It's probably irrelevant to the question, and the kind of answer you are expecting. But, can you please explain it to me what does this two lines mean?
matchedBoxPoints = boxPoints(boxPairs(:, 1), :);
matchedScenePoints = scenePoints(boxPairs(:, 2), :);
Thank you very much. It's kind of urgent.
  1 Comment
yanqi liu
yanqi liu on 29 Sep 2021
sir, may be the first is one image match features, and the second is the other image mach features.
it is made to match image box block.

Sign in to comment.


yanqi liu
yanqi liu on 29 Sep 2021
Edited: yanqi liu on 29 Sep 2021
sir,may be you should update the version of matlab
please check the follow code to get some information
clc; clear all; close all;
% Reading the reference Image
I= imread('viprectification_deskLeft.png');
C=rgb2gray(I);
boxImage = C;
figure; imshow(boxImage);
title('Image Left');
%Reading the target image
II= imread('viprectification_deskRight.png');
CC=rgb2gray(II);
sceneImage = CC;
figure;
imshow(sceneImage);
title('Image Right');
%Detect feature images
boxPoints = detectSURFFeatures(boxImage);
scenePoints = detectSURFFeatures(sceneImage);
%Visualize the strongest feature points found in the reference image.
figure;
imshow(boxImage);
title('100 Strongest Feature Points from Box Image');
hold on;
plot(boxPoints.selectStrongest(100));
%Visualize the strongest feature points found in the target image.
figure;
imshow(sceneImage);
title('300 Strongest Feature Points from Scene Image');
hold on;
plot(scenePoints.selectStrongest(300));
%Extract feature descriptors at the interest points in both images.
[boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints);
[sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints);
%Match the features using their descriptors.
boxPairs = matchFeatures(boxFeatures, sceneFeatures);
%Display putatively matched features.
matchedBoxPoints = boxPoints(boxPairs(:, 1), :);
matchedScenePoints = scenePoints(boxPairs(:, 2), :);
figure;
title('Putatively Matched Points (Including Outliers)');
%This is line 46 where the compiler is indicating an error*
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,...
matchedScenePoints,'montage');
%estimateGeometricTransform calculates the transformation relating the matched points,
%while eliminating outliers. This transformation allows us to localize the object in the scene.
[tform, inlierBoxPoints, inlierScenePoints] = estimateGeometricTransform(matchedBoxPoints, ...
matchedScenePoints, 'affine');
%Display the matching point pairs with the outliers removed
figure;
showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints,...
inlierScenePoints, 'montage');
title('Matched Points (Inliers Only)');
%Get the bounding polygon of the reference image.
boxPolygon = [1, 1;... % top-left
size(boxImage, 2), 1;... % top-right
size(boxImage, 2), size(boxImage, 1);... % bottom-right
1, size(boxImage, 1);... % bottom-left
1, 1]; % top-left again to close the polygon
% Transform the polygon into the coordinate system of the target image. The transformed polygon indicates the location of the object in the scene.
newBoxPolygon = transformPointsForward(tform, boxPolygon);
%Display the detected object.
figure();
imshow(sceneImage);
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');

yanqi liu
yanqi liu on 29 Sep 2021
Edited: yanqi liu on 29 Sep 2021
sir,please check the follow code to get some information
clc; clear all; close all;
I = imread('cameraman.tif');
I=imresize(I, [1e3 1e3], 'bilinear');
T = projective2d([0.89 1.24 0.002;
-0.95 1 0.0025;
0 0 1]);
J = imwarp(I(400:800,400:800),T);
% Reading the reference Image
C=J;
boxImage = C;
figure; imshow(boxImage);
title('Image of a Box');
%Reading the target image
II = I;
CC=II;
sceneImage = CC;
figure;
imshow(sceneImage);
title('Image of a Cluttered Scene');
%Detect feature images
boxPoints = detectSURFFeatures(boxImage);
scenePoints = detectSURFFeatures(sceneImage);
%Visualize the strongest feature points found in the reference image.
figure;
imshow(boxImage);
title('100 Strongest Feature Points from Box Image');
hold on;
plot(boxPoints.selectStrongest(100));
%Visualize the strongest feature points found in the target image.
figure;
imshow(sceneImage);
title('300 Strongest Feature Points from Scene Image');
hold on;
plot(scenePoints.selectStrongest(300));
%Extract feature descriptors at the interest points in both images.
[boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints);
[sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints);
%Match the features using their descriptors.
boxPairs = matchFeatures(boxFeatures, sceneFeatures);
%Display putatively matched features.
matchedBoxPoints = boxPoints(boxPairs(:, 1), :);
matchedScenePoints = scenePoints(boxPairs(:, 2), :);
figure;
title('Putatively Matched Points (Including Outliers)');
%This is line 46 where the compiler is indicating an error*
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,...
matchedScenePoints,'montage');
%estimateGeometricTransform calculates the transformation relating the matched points,
%while eliminating outliers. This transformation allows us to localize the object in the scene.
[tform, inlierBoxPoints, inlierScenePoints] = estimateGeometricTransform(matchedBoxPoints, ...
matchedScenePoints, 'affine');
%Display the matching point pairs with the outliers removed
figure;
showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints,...
inlierScenePoints, 'montage');
title('Matched Points (Inliers Only)');
%Get the bounding polygon of the reference image.
boxPolygon = [1, 1;... % top-left
size(boxImage, 2), 1;... % top-right
size(boxImage, 2), size(boxImage, 1);... % bottom-right
1, size(boxImage, 1);... % bottom-left
1, 1]; % top-left again to close the polygon
% Transform the polygon into the coordinate system of the target image. The transformed polygon indicates the location of the object in the scene.
newBoxPolygon = transformPointsForward(tform, boxPolygon);
%Display the detected object.
figure();
imshow(sceneImage);
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!