I intend to use Brief descriptor. But I am getting this undefined reference error. There is no problem with building the code. But the linker gives the error. Please let me know what have I missed. Thanks in advance.
Here's the code
#include <iostream>
#include <cmath>
#include "opencv2/opencv.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "harris_corner.h"
using namespace std;
class KeypointDescriptor {
public:
KeypointDescriptor();
virtual ~KeypointDescriptor() {}
void generate_keypoints(HarrisCorner&, cv::Mat&);
void compute_descriptor(HarrisCorner&, cv::Mat&);
cv::Ptr<cv::xfeatures2d::BriefDescriptorExtractor> desc_extr = cv::xfeatures2d::BriefDescriptorExtractor::create();
cv::Mat descriptors;
vector<cv::KeyPoint> kp;
};
The CMakeLists.txt is as below
cmake_minimum_required(VERSION 3.5)
project(Harris_Corner_Detector_fromScratch)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug)
ENDIF()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/build/cmake)
find_package(OpenCV REQUIRED)
add_compile_options(-std=c++11)
include_directories(include
${PROJECT_SOURCE_DIR}/
${PROJECT_SOURCE_DIR}/include/
${OpenCV_INCLUDE_DIRS}
)
add_library(HarrisCorner SHARED src/source_code/harris_corner.cpp)
add_library(KeypointDescriptor SHARED src/source_code/keypoint_descriptor.cpp)
add_executable(find_corner src/find_corner.cpp)
target_link_libraries(find_corner ${OpenCV_LIBS}
HarrisCorner)
add_executable(stitch_image src/stitch_image.cpp)
target_link_libraries(stitch_image ${OpenCV_LIBS}
HarrisCorner
KeypointDescriptor)
The output is as follows
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tyagaraja/WPI/ARN/HW/Week10/Harris_Corner_Detector_fromScratch/build
[ 25%] Built target HarrisCorner
[ 50%] Built target KeypointDescriptor
[ 62%] Linking CXX executable stitch_image
libKeypointDescriptor.so: undefined reference to `cv::xfeatures2d::BriefDescriptorExtractor::create(int, bool)'
collect2: error: ld returned 1 exit status
CMakeFiles/stitch_image.dir/build.make:141: recipe for target 'stitch_image' failed
make[2]: *** [stitch_image] Error 1
CMakeFiles/Makefile2:105: recipe for target 'CMakeFiles/stitch_image.dir/all' failed
make[1]: *** [CMakeFiles/stitch_image.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I am using OpenCV that comes default with ROS Kinetic
Aucun commentaire:
Enregistrer un commentaire