Undefined reference to cv::Feature2D::compute
Hi,
I am running ROS Hydro and OpenCV 2.4.7, using openFabMap and SURF. When I do catkin_make on my project, I get the following error:
undefined reference to `cv::Feature2D::compute(cv::Mat const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat&) const'
I noticed that this happens when I write the following line of code:
cv::SurfDescriptorExtractor extractor;
extractor.compute( cv_ptr->image, keypoints, descriptors_img);
UPDATE Other cv classes, such as the cv::SurfFeatureDetector detector class work normally. It even instantiates the cv::SurfDescriptorExtractor extractor with no problem. If I comment the "extractor.compute" call, I get no error.
I am including the following on the header:
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/opencv.hpp>
UPDATE And my (complete this time) CMakeLists:
cmake_minimum_required(VERSION 2.8.3)
project(compvision)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
image_transport
cv_bridge
sensor_msgs
message_generation
)
find_package(OpenCV 2.4.7 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_message_files(
FILES
Match.msg
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES compvision
# CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS}
)
include_directories(
${OpenCV_INCLUDE_DIRS}
)
add_executable(openFABMAPros src/fabmapTest.cpp)
target_link_libraries(openFABMAPros ${catkin_LIBRARIES})
target_link_libraries(openFABMAPros ${OpenCV_LIBRARIES})
add_dependencies(openFABMAPros ${catkin_EXPORTED_TARGETS})
add_executable(image_converter src/image_converter.cpp)
target_link_libraries(image_converter ${catkin_LIBRARIES})
target_link_libraries(image_converter ${OpenCV_LIBRARIES})
add_dependencies(image_converter ${catkin_EXPORTED_TARGETS})
Am I missing some dependencies? I don't recall this error happening when building with earlier versions of OpenCV.
Thanks for your time and support.
Installing ROS on another machine and running the same code there worked just fine ... well, I still don't know what might have happened, but that solved the problem for me.