4

我正在使用 ORB 特征检测器和提取器从灰度图像列表中获取特征。问题是如果我尝试多次检测\提取它,我会从同一张图像中获得不同的特征。所以以后不可能用它们来检测。

编码:

bmp=BitmapFactory.decodeResource(getResources(),R.drawable.t1);
Utils.bitmapToMat(bmp, mat);
FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
detector.detect(mat, keypoints);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
extractor.compute(mat, keypoints, features);

也许有人对此有所了解?

4

1 回答 1

2

这不应该是这种情况..您应该获得一致的性能。但是,我正在共享我的代码以在两个图像上使用 Orb 特征检测器以及 Orb Descriptor Extractor。您可以使用任何匹配器来匹配它们。希望这可以帮助你...

#include "iostream"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/flann/flann.hpp>
#include <opencv2/legacy/legacy.hpp>
#include <vector>


using namespace cv;
using namespace std;

int main()
{
    Mat image1,image2;
    imageA = imread("C:\\lena.jpg",0);
    imageB = imread("C:\\lena1.bmp",0);

    vector<KeyPoint> keypointsA,keypointsB;
    Mat descriptorsA,descriptorsB;

    std::vector<DMatch> matches;

    OrbFeatureDetector detector;

    OrbDescriptorExtractor extractor;

    BruteForceMatcher<Hamming> matcher;

    detector.detect(imageA,keypointsA);
    detector.detect(imageB,keypointsB);

    extractor.compute(imageA,keypointsA,descriptorsA);
    extractor.compute(imageB,keypointsB,descriptorsB);

    return 0;
 }
于 2013-01-14T07:39:20.623 回答