简体   繁体   中英

converting from SURF descriptors to keypoints

i have to convert SURF descriptor to keypoints to mark it on the image.I have found the conversion function Converting Mat to Keypoint? . But the results i am getting are very strange.This is the following function.

vector<KeyPoint> mat_to_keypoints(Mat mat) {

  vector<KeyPoint>  c_keypoints;
  for ( int i = 0; i < mat.rows; i++) {

      Vec<float, 7> v = mat.at< Vec<float, 7> >(i,0);
      KeyPoint kp(v[0],v[1],v[2],v[3],v[4], (int)v[5], (int)v[6]);
      c_keypoints.push_back(kp);
  }
  return c_keypoints;
}

And this is my sample code

 SurfDescriptorExtractor surfDesc;
 Mat descriptors1;

 surfDesc.compute(img_test, keypoints1, descriptors1);
 Point2f p;
 std::vector<cv::KeyPoint> keypoint1_;

 keypoint1_= mat_to_keypoints(descriptors1);

for(int i=0;i<keypoint1_.size();i++)
{
   p = keypoint1_[i].pt;
  cout<<p<<endl;
}

There are the original keypoints

  [287.016, 424.287] 
  [286.903, 424.413] 

And these are keypoints after converting from descriptor to keypoints

-0.001208060.00063669 
00 
00 
00 
00 
0.002944490.00162154 
-0.0005055370.000337795 
0.00683623-0.00150546 

Could some one suggest me,how to convert from descriptors to keypoints?

Your are messing up descriptors with keypoints. Descriptors represent the feature vector associated to keypoints. Descriptors don't include the position (X,Y) of the patch they describe.

You cannot convert from a set of descriptors to a set of keypoints/points.

You can convert keypoints from points with this static method (undocumented):

vector<Point2f> points1; 
KeyPoint::convert(keypoints1, points1);

Sadly there are many undocumented/hidden function very helpful in OpenCV.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM