OpenCV ORB功能

时间:2013-01-14 07:15:13

标签: android opencv machine-learning computer-vision

我正在使用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);

也许有人对此有所了解?

1 个答案:

答案 0 :(得分:2)

情况不应该如此......你应该得到一致的表现。但是,我正在共享我的代码,以便在两个图像上使用Orb Feature检测器和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;
 }