Ask Your Question

undefined reference to `cv::xfeatures2d::SURF::create(double, int, int, bool, bool)' [closed]

asked 2017-03-09 08:59:28 -0500

YuriiChernyshov gravatar image


I have updated OpenCV c++ recently from 3.1 to 3.2 version and getting next error while compile:

undefined reference to `cv::xfeatures2d::SURF::create(double, int, int, bool, bool)'

My cmake file:

cmake_minimum_required(VERSION 3.6)
find_package(OpenCV REQUIRED)
set(SOURCE_FILES main.cpp SurfDetector.cpp SurfDetector.h ContoursDetector.cpp ContoursDetector.h)
add_executable(OpenCVProject ${SOURCE_FILES})
target_link_libraries(OpenCVProject ${OpenCV_LIBS})

And my header file is:

#include <stdio.h>
#include <iostream>
#include <opencv2/imgproc.hpp>
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/xfeatures2d.hpp"

using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;

Code snippet that cause the error:

Ptr<SURF> detector = SURF::create(400, 4, 3, true, true);

I compiled OpenCV from source, but previously I compiled opencv-contrib library following instruction in their readmy, exactly the way I did for version 3.1.

The question is there a bug or changes in 3.2 that I am not aware of?

Thanks in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by YuriiChernyshov
close date 2017-03-09 11:23:56.167471


Have you check if in cmake OPENCV_ENABLE_NONFREE is checked ?

LBerger gravatar imageLBerger ( 2017-03-09 09:14:20 -0500 )edit

It was OFF. However, I set it to ON and still have the same issue. Here is how I handled it:

set(OPENCV_ENABLE_NONFREE "Enable non-free algorithms" ON)

    message("  Non-free algorithms are enabled")
    message("  Non-free algorithms are NOT enabled")
YuriiChernyshov gravatar imageYuriiChernyshov ( 2017-03-09 09:50:05 -0500 )edit

@LBerger , btw, OPENCV_ENABLE_NONFREE seems to be used only in bm3d_image_denoising ..

not with SIFT or SURF, as one might expect. weird, isn't it ?

berak gravatar imageberak ( 2017-03-10 00:54:54 -0500 )edit

Yes I am agree but in doc it is non free : an issue ? OPENCV_ENABLE_NONFREE what does it means?

LBerger gravatar imageLBerger ( 2017-03-10 01:08:08 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-03-09 11:17:33 -0500

YuriiChernyshov gravatar image

updated 2017-03-09 11:17:55 -0500

Ok, I solved the issue. I install again version 3.2 and then invoked:

sudo make uninstall

Then did the same for version 3.1 Then ran:

sudo apt-get purge libopencv*

Then, when everything was cleaned, I installed version 3.2 from scratch including contrib lib. Everything works fine now :-)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-03-09 08:59:28 -0500

Seen: 2,616 times

Last updated: Mar 09 '17