Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have finally found a solution for compiling with a CMakeLists.txt file while using opencv2.4 installed through ROS. You just have to write: (Text that is not bold are just comments )

cmake needs this line cmake_minimum_required(VERSION 2.8)

Define project name
project(Pruebas_alg)

Find OpenCV, you may need to set OpenCV_DIR variable to the absolute path to the directory containing OpenCVConfig.cmake file via the command line or GUI find_package(OpenCV REQUIRED)

If the package has been found, several variables will be set, you can find the full list with descriptions in the OpenCVConfig.cmake file. Print some message showing some of them
message(STATUS "OpenCV library status:") message(STATUS " config: ${OpenCV_DIR}") message(STATUS " version: ${OpenCV_VERSION}") message(STATUS " libraries: ${OpenCV_LIBS}") message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")

include_directories(${OpenCV_INCLUDE_DIRS})

Declare the executable target built from your sources
add_executable(FAST_implementation Fast_alg.cpp) add_executable(ORB_implementation orb_alg.cpp) add_executable(BRISK_implementation brisk_alg.cpp) add_executable(BRISK_Match Matcher_BRISK.cpp) add_executable(ORB_Match Matcher_ORB.cpp) add_executable(Executable_name script.cpp)

Link your application with OpenCV libraries
target_link_libraries(FAST_implementation PRIVATE ${OpenCV_LIBS}) target_link_libraries(ORB_implementation PRIVATE ${OpenCV_LIBS}) target_link_libraries(BRISK_implementation PRIVATE ${OpenCV_LIBS}) target_link_libraries(BRISK_Match PRIVATE ${OpenCV_LIBS}) target_link_libraries(ORB_Match PRIVATE ${OpenCV_LIBS}) target_link_libraries(Executable_name PRIVATE ${OpenCV_LIBS})

I have not been able to add SURF program, so I have opted for installing OpenCV 3.4 (no need to upgrade CMake) and so it looks like it works. No trouble (at least yet) with ROS or Gazebo.