Ask Your Question
0

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

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

YuriiChernyshov gravatar image

Hi,

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)
project(OpenCVProject)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "-O3")
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

Comments

Have you check if in cmake OPENCV_ENABLE_NONFREE is checked ?

LBerger gravatar imageLBerger ( 2017-03-09 09:14:20 -0600 )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)

if(OPENCV_ENABLE_NONFREE)
    message("  Non-free algorithms are enabled")
else()
    message("  Non-free algorithms are NOT enabled")
endif()
YuriiChernyshov gravatar imageYuriiChernyshov ( 2017-03-09 09:50:05 -0600 )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 -0600 )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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

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

YuriiChernyshov gravatar image

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

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

Stats

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

Seen: 3,650 times

Last updated: Mar 09 '17