How do I use nonfree opencv Libraries in ROS
Hello, I need to use a SURF feature detector in ros. I succeded when I used it outside ROS, but when i try to make a code for a node in ROS, the compiler shows me this:
CMakeFiles/stream_node.dir/src/stream_node.cpp.o: In function `ImageConverter::imageCb(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&)':stream_node.cpp: (.text._ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE[_ZN14ImageConverter7imageCbERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEE]+0x134): undefined reference to `cv::SURF::SURF(double, int, int, bool, bool)'
CMakeFiles/stream_node.dir/src/stream_node.cpp.o: In function `cv::SURF::~SURF()':
stream_node.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0xe): undefined reference to `vtable for cv::SURF'
stream_node.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0x26): undefined reference to `vtable for cv::SURF'
stream_node.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0x2e): undefined reference to `vtable for cv::SURF'
stream_node.cpp:(.text._ZN2cv4SURFD1Ev[_ZN2cv4SURFD1Ev]+0x3b): undefined reference to `VTT for cv::SURF'
collect2: error: ld returned 1 exit status
I understand it is because SURF is ubicated in a nonfree library of opencv, then, my includes are:
#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 <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
However, It still doesnt work. Somebody knows what I have to do? Maybe editing the CMakeList.txt?
Thanks!