I'm trying to create a showMatchedFeatures function similar to that of MATLAB, using OpenCV library in C++.
A matchFeatures function has already been made which takes as parameters two features f1 & f2 which are matrices of type double containing the computed feature vector by SURF. This function manually computes the descriptors i.e the feature vectors. So there was no need of using the extractor method of SurfDescriptorExtractor class which is used in the FlannBasedMatcher tutorial.
After that it computes the matches using FLANN Based approach and and returns the matches which are used as parameters in the showMatchedFeatures function.
Now the showMatchedFeatures function only has to draw the matches using drawMatches function of OpenCv but the problem is even though lines are drawn, it doesn't match the same feature points. Only 1 or 2 points get matched properly but the rest are completely wrong.
So I was wondering whether the feature vector computed was wrong and that's why maybe I'm getting the error since I didn't use OpenCV extractor method of SurfDescriptorExtractor class ?
Code- matchFeatures function(lines 376-461 does the feature vector computation) -The function can't return a Dmatch(OpenCV) object but can return pointers of double datatype, so I took the important members of the object like queryIdx,trainIDx and distance and stored it in a double array and as 3 parameters are passed to showMatchedFeatures function where they are combined to create a new Dmatch object and with this, drawMatches function is used.
showMatchedFeatures function(lines 146 - 190 )- Contains the creation of Dmatch object and drawing the good matches.
Link to code--https://drive.google.com/open?id=0B3jt6sHgpxO-eVBPNTlheW1reGs