我必须将 SURF 描述符转换为关键点才能在图像上标记它。我找到了转换函数Converting Mat to Keypoint? . 但是我得到的结果很奇怪。这是以下功能。
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;
}
这是我的示例代码
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;
}
有原来的关键点
[287.016, 424.287]
[286.903, 424.413]
这些是从描述符转换为关键点后的关键点
-0.001208060.00063669
00
00
00
00
0.002944490.00162154
-0.0005055370.000337795
0.00683623-0.00150546
有人可以建议我,如何从描述符转换为关键点?