Ask Your Question
0

How do I use SIFT in ROS project

asked 2018-03-15 11:29:36 -0500

Kri gravatar image

updated 2018-03-15 11:32:50 -0500

How to set everything in my project, so that I can use some existing solution for SIFT?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-15 11:29:55 -0500

Kri gravatar image

updated 2018-03-15 11:34:19 -0500

If you have a ROS project and you want to use SIFT algorithm, there is an implementation in OpenCV library.

If you choose the OpenCV 3, you will need to download an external modul opencv_contrib and give it as a flag to the cmake while installing the OpenCV 3 library. I haven't manage to make this solution work, since other packages in my project requested OpenCV 2.

I used OpenCV 2.4.8.

  1. Download the source code
  2. Make a new folder inside the OpenCV 2.4.8 folder. Name it 'build'
  3. In console, go into 'build' folder and run following commands

Commands:

  1. cmake -D CMAKE_INSTALL_PREFIX=/usr/include/ ..
  2. make
  3. sudo make install

the '/usr/include/' is the path where the OpenCV will be installed.

'..' tells the cmake where to find the source code for the OpenCV (that means one folder up).

When you have the OpenCV installed, you have to link it with your ROS project. In the 'CMakeLists.txt' of your project add following lines:

 find_package(OpenCV 2.4.8 EXACT REQUIRED)

 SET(OpenCV_LIBRARIES opencv_core opencv_highgui opencv_imgproc opencv_nonfree opencv_features2d)

 catkin_package(
 DEPENDS system_lib opencv2
 ...
 )

 include_directories(
 ${OpenCV_INCLUDE_DIRS}
 ...
 )

 target_link_libraries( ${PROJECT_NAME}_my_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

When you set 'OpenCV_LIBRARIES' you can only set those that you actually need. I left there all the other libraries because I think you will use then in your project anyway.

You have to include the header files into your project source file.

#include <opencv2/opencv.hpp>
#include <opencv2/nonfree/nonfree.hpp>

Now you can use one of the many examples to use SIFT in your project. For example here, here or here.

edit flag offensive delete link more

Comments

3

If you do this, be aware of possible binary incompatibility problems between pkgs that link against the 'ROS version' of OpenCV and your OpenCV in /usr/local.

gvdhoorn gravatar imagegvdhoorn ( 2018-03-15 11:42:51 -0500 )edit

@gvdhoorn Can you please explain in more detail? I was confused by this exact thing, but I'm new to ubuntu and don't understand how this works yet.

Kri gravatar imageKri ( 2018-03-15 14:57:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-15 11:29:36 -0500

Seen: 198 times

Last updated: Mar 15 '18