Arxeiss
Arxeiss

Reputation: 1046

OpenCV drawMatches do nothing

I'm trying to find matching point of interest on 2 images. Final of this project is to build panorama.

I have this code

SIFT detector(0);

src1 = imread( folder + inputName1 , 1 );
cvtColor( src1, src1_gray, CV_BGR2GRAY );
// Detect first image
vector<KeyPoint> keypoints1;
detector.detect(src1_gray, keypoints1);
//Draw keypoints back to source image
drawKeypoints(src1,keypoints1,src1,Scalar::all(-1), 1);
imwrite(folder + outputName1,src1);


src2 = imread( folder + inputName2 , 1 );
cvtColor( src2, src2_gray, CV_BGR2GRAY );
// Detect second image
vector<KeyPoint> keypoints2;
detector.detect(src2_gray, keypoints2);
//Draw keypoints back to source image
drawKeypoints(src2,keypoints2,src2,Scalar::all(-1), 1); 
imwrite(folder + outputName2,src2);

vector<DMatch> matches;
Mat output;

drawMatches(src1,keypoints1,src2,keypoints2,matches,output);

imwrite(folder + "matches.jpg",output);

But in final image matches.jpg, all points are shown, and vector matches is empty. What I am doing wrong? I thought, that only matching points will be in final image, and in vector matches I find coordinates to draw lines between points.

Or should I use RANSAC for find matching points?

Upvotes: 1

Views: 4148

Answers (1)

&#216;ystein W.
&#216;ystein W.

Reputation: 517

You have not matched any points. Look at this example: http://docs.opencv.org/doc/user_guide/ug_features2d.html.

You need to extract descriptors and then match them with FLANN for instance. Then you can draw your matches ;)

Upvotes: 3

Related Questions