小编khu*_*ram的帖子

比较.yml文件OpenCV中的图像SIFT/SURF细节?

我是java android开发人员,我不太了解C/C++或Matlab函数.在我的代码中做的很简单的事情就是创建sift/Surf图像细节并在.yml文件中保存细节.

这是我如何创建筛选的代码

vector < KeyPoint > keypoints;
Mat descriptors;
// Create a SIFT keypoint detector.
SiftFeatureDetector detector;
detector.detect(image, keypoints);
LOGI("Detected %d keypoints\n", (int) keypoints.size());
// Compute feature description.
detector.compute(image, keypoints, descriptors);
Run Code Online (Sandbox Code Playgroud)

将结果描述符保存在(.yml)文件中,然后使用OpenCV的FlannBasedMatcher比较yml文件

这是我的代码

descriptors1&descriptors2是从.yml文件创建的两个mat对象.

FlannBasedMatcher matcher;
vector<double> ee;
vector < DMatch > good_matches;
double good_matches_sum = 0.0;
vector < vector<DMatch> > matches;
matcher.knnMatch(descriptors1, descriptors2, matches, 2);
for (int i = 0; i < matches.size(); i++) {
   if (matches[i][0].distance < 0.8 * matches[i][1].distance) {

       good_matches.push_back(matches[i][0]);
       good_matches_sum += matches[i][0].distance;
    }
} …
Run Code Online (Sandbox Code Playgroud)

c java-native-interface android opencv opencv4android

8
推荐指数
1
解决办法
1098
查看次数