Ask Your Question

Non-free feature detectors in 3.0

asked 2014-10-12 04:27:42 -0500

CraigH gravatar image

updated 2014-10-14 02:35:53 -0500

I have built 3.0 from mastering git with opencv_contrib configured. How do I get the nonfree detectors registered so they can be created throught the object factories FeatureDetector::create() etc? The old init functions aren't available. I'm specifically looking for SIFT and SURF.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-10-12 06:55:25 -0500

berak gravatar image

updated 2014-10-23 03:54:08 -0500

in 3.0, SIFT and SURF were moved to the opencv_contrib repo

you will need to clone/fork/download that, and add that to your cmake;

cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules

then, after building,

#include "opencv2/xfeatures2d/nonfree.hpp"

if you want to use SIFT/SURF directly, it's

[EDIT: latest refactoring removed a lot of possibilities. you can't create a'stack' object anymore, also, the 'factory functions'(Algorithm) are gone. ]

xfeatures2d::SURF surf;

Ptr<xfeatures2d::SURF> surf = xfeatures2d::SURF::create();

if you want the factory functions:

xfeatures2d::initModule_xfeatures2d(); // note additional namespace
Ptr<FeatureDetector> sift = FeatureDetector::create("SIFT");

last, you will have to link against opencv_xfeatures2d.

edit flag offensive delete link more


I've done all the building, but it's the factory bit that doesn't work. In 2.x, you call cv::initModule_nonfree(); to initialise, but that is missing in 3.0 and the call to FeatureDetector::create() fails for nonfree descriptors.

CraigH gravatar imageCraigH ( 2014-10-12 07:44:16 -0500 )edit

Ok, so now I'm missing the library for cv::features2d::SIFT, and get unresolved externals. Which library should it be in?

CraigH gravatar imageCraigH ( 2014-10-12 09:23:51 -0500 )edit

you will have to link opencv_xfeatures2d, sorry for not mentioning this before ;)

again, it seems safer atm, to create an instance directly, like

xfeatures2d::SURF surf2;

cerr << << endl;

berak gravatar imageberak ( 2014-10-12 09:27:04 -0500 )edit

Hmm, i must be building it wrong. I don't have an xfeatures2d lib :(

CraigH gravatar imageCraigH ( 2014-10-12 09:46:41 -0500 )edit

look at the cmake output, if it was enabled or not.(or why)

older versions had xfeatures2d disabled by cudaarithm dependancy , maybe you want to update the whole schlepp.

berak gravatar imageberak ( 2014-10-12 09:58:05 -0500 )edit

I pulled the latest from git, both opencv and opencv_contrib and with your extra line, it all now works. Thanks for all your help!

CraigH gravatar imageCraigH ( 2014-10-12 10:21:30 -0500 )edit

@berak: guess, initModule_xfeatures2d() solves that issue

Guanta gravatar imageGuanta ( 2014-10-12 10:43:38 -0500 )edit

xfeatures2d::initModule_xfeatures2d(); thanks, @Guanta

berak gravatar imageberak ( 2014-10-12 10:59:43 -0500 )edit

Hi all: old style : Ptr<SIFT> sift=new SIFT(nfeatures,nOctaveLayers,contrastThreshold,edgeThreshold,sigma) But in OpenCV3.0: How to set up those params?

wuling gravatar imagewuling ( 2014-10-14 02:52:01 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-10-12 04:27:42 -0500

Seen: 4,796 times

Last updated: Oct 23 '14