Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV 2.42 FeatureDetector FREAK

Tags:

c++

opencv

I want to try the new class FREAK in OpenCV 2.4.2.

I tried to use common interface of feature detector to construct FREAK, but,of course, it doesn't work. How should I revise my code to get result?

#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);

}
like image 575
Jason C Avatar asked Oct 15 '12 17:10

Jason C


2 Answers

FREAK is descriptor only. There is no corresponding feature detector.

So you need to combine it with one of the available detectors: FAST, ORB, SIFT, SURF, MSER or use goodFeaturesToTrack function.

like image 144
Andrey Kamaev Avatar answered Nov 15 '22 11:11

Andrey Kamaev


There is an OpenCV example that shows how to use FREAK combined with FAST.

The basic instructions are:

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);
like image 24
Mar de Romos Avatar answered Nov 15 '22 13:11

Mar de Romos