Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ROS: OpenCV SURF is there but can't be found

I was able to run OpenCV with ROS. I have run basic things (like loading images, getting video stream ect) but I am trying to run SURF or SIFT and I get this error:

Linking CXX executable /home/jim/ROS/catkin_ws/devel/lib/opencv_ros/open
CMakeFiles/open.dir/src/open.cpp.o: In function `main':
open.cpp:(.text+0x15b): undefined reference to `cv::SURF::SURF(double, int, int, bool, bool)'
CMakeFiles/open.dir/src/open.cpp.o: In function `cv::SURF::~SURF()':
open.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0xe): undefined reference to `vtable for cv::SURF'
open.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0x26): undefined reference to `vtable for cv::SURF'
open.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0x2e): undefined reference to `vtable for cv::SURF'
open.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0x3b): undefined reference to `VTT for cv::SURF'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/jim/ROS/catkin_ws/devel/lib/opencv_ros/open] Error 1
make[1]: *** [opencv_ros/CMakeFiles/open.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

The project name is "opencv_ros" and the code is in "open.cpp". I have include these headers:

#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"

the thing is that when I run the same code in my c++ IDE (code::blocks) it runs just fine. I even found the header file and saw that it's in the correct place (according to the include I gave).

In the ROS ask website, they told me that I am doing something wrong with OpenCV and the make file. They said I should ask here for help. Here is my CMakeLists.txt :

cmake_minimum_required(VERSION 2.8.3)
project(opencv_ros)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  sensor_msgs
  std_msgs
)

catkin_package(  CATKIN_DEPENDS cv_bridge image_transport roscpp sensor_msgs std_msgs )

include_directories(${catkin_INCLUDE_DIRS})

add_executable(open src/open.cpp)
target_link_libraries(open ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
add_dependencies(open opencv_ros_generate_messages_cpp)

I am running ubuntu 14.04 64bit on Indigo with OpenCV 2.4.9 .

Why cant it find SURF or SIFT in ROS?