OpenCV 2.42 FeatureDetector FREAK

时间:2012-10-15 17:04:56

标签: c++ opencv

我想在OpenCV 2.4.2中尝试新的类FREAK

我尝试使用特征检测器的通用接口来构造FREAK,但是,当然,它不起作用。我应该如何修改我的代码以获得结果?

#include <stdio.h>
#include <iostream>
#include <opencv\cxcore.h>
#include <opencv2\nonfree\features2d.hpp>
#include <opencv\highgui.h>
#include <opencv2\features2d\features2d.hpp>
#include <vector>

using namespace std;
using namespace cv;

int main(){
    Mat mat1;
    mat1 = imread("Testimg06.jpg",0);
    vector<KeyPoint> P1;
    Ptr<FeatureDetector> freakdes;
    Ptr<DescriptorExtractor> descriptorExtractor; 
    freakdes = FeatureDetector::create("FREAK"); 

    freakdes->detect(mat1,P1);

    Mat keypoint_img;

    drawKeypoints( mat1, P1, keypoint_img, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
     imshow("Keypoints 1", keypoint_img );
    cvWaitKey(0);

}

2 个答案:

答案 0 :(得分:8)

FREAK仅是描述符。没有相应的特征检测器。

因此,您需要将其与一个可用的检测器结合使用:FAST,ORB,SIFT,SURF,MSER或使用goodFeaturesToTrack功能。

答案 1 :(得分:7)

OpenCV example显示了如何将FREAK与FAST结合使用。

基本说明如下:

FREAK extractor;
BruteForceMatcher<Hamming> matcher;
std::vector<KeyPoint> keypointsA, keypointsB;
Mat descriptorsA, descriptorsB;
std::vector<DMatch> matches;

FAST(imgA,keypointsA,10);
FAST(imgB,keypointsB,10);

extractor.compute( imgA, keypointsA, descriptorsA );
extractor.compute( imgB, keypointsB, descriptorsB );

matcher.match(descriptorsA, descriptorsB, matches);
相关问题