OpenCV 2.42 特征检测器 FREAK

10

我想尝试在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个回答

8

FREAK只是一个描述符,没有相应的特征检测器。

因此,您需要将其与现有的检测器之一结合使用:FAST、ORB、SIFT、SURF、MSER或使用goodFeaturesToTrack函数。


非常感谢!这是否意味着我应该使用DescriptorExtractor将FREAK设置为特征描述符? - Jason C

7

有一个OpenCV示例展示了如何将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);

1
请注意,为了获得最佳性能,FREAK需要旋转和尺度不变的关键点,因此FAST并不是最佳选择,更多信息请参见“二进制关键点描述符评估”:http://2013.ieeeicip.org/proc/pdfs/0003652.pdf。 - aledalgrande

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接