I tried to use SURF detector and descriptor in opencv3.0.0. However, the error is
Undefined symbols for architecture x86_64:
"cv::xfeatures2d::SURF::create(double, int, int, bool, bool)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
QT project setting
QT += core
QT -= gui
TARGET = test4
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += /usr/local/include
INCLUDEPATH += /usr/local/include/opencv
INCLUDEPATH += /usr/local/include/opencv2
LIBS += -L/usr/local/lib \
-lopencv_calib3d \
-lopencv_core \
-lopencv_features2d \
-lopencv_flann \
-lopencv_highgui \
-lopencv_imgcodecs \
-lopencv_imgproc \
-lopencv_ml \
-lopencv_objdetect \
-lopencv_photo \
SOURCES += main.cpp
Code
#include <iostream>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/opencv.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>
using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;
int main(int argc, char *argv[])
{
Mat img_1 = imread( "../testImg/left.jpg", CV_LOAD_IMAGE_GRAYSCALE );
Mat img_2 = imread( "../testImg/right.jpg", CV_LOAD_IMAGE_GRAYSCALE );
imshow("Display1",img_1);
imshow("Display2",img_2);
if( !img_1.data || !img_2.data ){ std::cout<< 'no image loaded' <<std::endl; }
std::cout<< 'it works!' <<std::endl;
//-- Step 1: Detect the keypoints using SURF Detector
double minHessian = 1000;
Ptr<Feature2D> f2d = SURF::create(minHessian);
// Ptr<Feature2D> f2d = ORB::create();
}
I have checked that nonfree and xfeatures2d are already installed by using cmake.
Ptr<Feature2D> f2d = ORB::create(); // is worked but SURF and SIFT don't.
Compiler Error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.10 -Wl,-rpath,/Users/tianshi/Qt/5.5/clang_64/lib -o test_cv.app/Contents/MacOS/test_cv main.o mainwindow.o moc_mainwindow.o -F/Users/tianshi/Qt/5.5/clang_64/lib -L/usr/local/lib -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -framework QtOpenGL -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL
Undefined symbols for architecture x86_64:
"cv::xfeatures2d::SIFT::create(int, int, double, double, double)", referenced from:
MainWindow::MainWindow(QWidget*) in mainwindow.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test_cv.app/Contents/MacOS/test_cv] Error 1
Error while building/deploying project test_cv (kit: Desktop Qt 5.5.0 clang 64bit)
When executing step "Make"
22:04:37: Elapsed time: 00:00.