0

I'm using openCV 2.4, where I'm using FlannBasedMatcher to match keypoints. However, instead of using SurfFeatureDetector::detect()to extract keypoints, I'm passing the image corners as keypoints.

Sadly I'm getting zero matches for all values of minHessian.

Below is my code:

void matches(int, void*)

{


SurfFeatureDetector detector( minHessian );

vector<KeyPoint> keypoints_frame,keypoints_trng;
Mat descriptors_frame,descriptors_trng;
//detect keypoints



for(int i=0;i<corners.size();i++)
    {
      keypoints_frame.push_back(KeyPoint(corners[i].x,corners[i].y,0));
    cout<<"\n"<<keypoints_frame[i].pt.x<<"\t"<<keypoints_frame[i].pt.y;
    }
keypoints_trng.push_back(KeyPoint(337,288,0));
keypoints_trng.push_back(KeyPoint(337,241,0));
keypoints_trng.push_back(KeyPoint(370,288,0));
keypoints_trng.push_back(KeyPoint(370,241,0));
keypoints_trng.push_back(KeyPoint(291,239,0));
keypoints_trng.push_back(KeyPoint(287,203,0));
keypoints_trng.push_back(KeyPoint(288,329,0));
keypoints_trng.push_back(KeyPoint(426,237,0));
keypoints_trng.push_back(KeyPoint(428,326,0));
keypoints_trng.push_back(KeyPoint(426,201,0));
keypoints_trng.push_back(KeyPoint(427,293,0));
keypoints_trng.push_back(KeyPoint(287,297,0));

for(int i=0;i<corners.size();i++)
    {

    cout<<"\n"<<keypoints_trng[i].pt.x<<"\t"<<keypoints_trng[i].pt.y;
    }
//describe keypoints

SurfDescriptorExtractor extractor;
extractor.compute( src_gray_resized, keypoints_frame, descriptors_frame);
extractor.compute( trng_gray_resized, keypoints_trng, descriptors_trng);

//matching the keypoints
  FlannBasedMatcher matcher;
  std::vector< DMatch > matches;
  matcher.match( descriptors_frame, descriptors_trng, matches );
cout<<"\n\n no of matches: "<<matches.size();
std::vector< DMatch > good_matches;
if (matches.size()>20)
{minHessian=minHessian+100;}


  for( int i = 0; i < descriptors_frame.rows; i++ )
  { if( matches[i].distance <= max(2*100.00, 0.02) )
            { good_matches.push_back( matches[i]); }
  }
//cout<<"\nno of good matches"<<good_matches.size();
  //-- Draw only "good" matches
  Mat img_matches;
  drawMatches( src_gray, keypoints_frame, trng_gray, keypoints_trng,
               good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
               vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );

  //-- Show detected matches
namedWindow("Good Matches",CV_WINDOW_NORMAL);
  imshow( "Good Matches", img_matches );

}
  • Have you validated the corners you pass yourself? Have you tried using the detector and check the matches? – Rick M. Jul 24 '17 at 11:55
  • yes! i validated the output of `push_back(KeyPoint()) ` and my corner positions in the image. They are conformable to each other. My problem starts at `extractor.compute()` – Krishna Chouthankar Jul 24 '17 at 12:09
  • This question required more information that you have provided, how do you get these corners you are talking about? Look at [the definition of KeyPoint](http://docs.opencv.org/trunk/d2/d29/classcv_1_1KeyPoint.html), you need other properties along with the location in (x,y) – Rick M. Jul 24 '17 at 12:13

0 Answers0