How to tell Catkin_make to use opencv with gpu?
Hi.
I have same trouble with this Having trouble using CUDA enabled OpenCV with kinetic.
My trouble is catkin_make is looking into only non-cuda function for ros-kinetic even I use NO_MODULE to tell exact opencv path.
Test CMakeLists.txt
So I made a test with CMakeLists.txt with following statement.
# find_package(Boost REQUIRED COMPONENTS system)
find_package(OpenCV REQUIRED
NO_MODULE # should be optional, tells CMake to use config mode
PATHS /usr/local # look here
NO_DEFAULT_PATH) # and don't look anywhere else
MESSAGE(WARNING "prefix ${CMAKE_PREFIX_PATH}")
MESSAGE(WARNING "version ${OpenCV_VERSION}")
MESSAGE(WARNING "install path ${OpenCV_INSTALL_PATH}")
MESSAGE(WARNING "config path ${OpenCV_CONFIG_PATH}") # look at the output of this message
MESSAGE(WARNING "include dirs ${OpenCV_INCLUDE_DIRS}")
MESSAGE(WARNING "libs ${OpenCV_LIBS}")
Test result
As a result, I can see catkin_make can correctly locate my opencv with cuda.
CMake Warning at CMakeLists.txt:10 (MESSAGE):
version 3.1.0
CMake Warning at CMakeLists.txt:11 (MESSAGE):
install path /usr/local
CMake Warning at CMakeLists.txt:12 (MESSAGE):
config path /usr/local/share/OpenCV
CMake Warning at CMakeLists.txt:13 (MESSAGE):
include dirs /usr/local/include/opencv;/usr/local/include
CMake Warning at CMakeLists.txt:14 (MESSAGE):
libs
opencv_xphoto;opencv_xobjdetect;opencv_ximgproc;opencv_xfeatures2d;opencv_tracking;opencv_text;opencv_surface_matching;opencv_structured_light;opencv_stereo;opencv_sfm;opencv_saliency;opencv_rgbd;opencv_reg;opencv_plot;opencv_optflow;opencv_line_descriptor;opencv_hdf;opencv_fuzzy;opencv_face;opencv_dpm;opencv_dnn;opencv_datasets;opencv_cvv;opencv_ccalib;opencv_bioinspired;opencv_bgsegm;opencv_aruco;opencv_videostab;opencv_videoio;opencv_video;opencv_superres;opencv_stitching;opencv_shape;opencv_photo;opencv_objdetect;opencv_ml;opencv_imgproc;opencv_imgcodecs;opencv_highgui;opencv_flann;opencv_features2d;opencv_cudev;opencv_cudawarping;opencv_cudastereo;opencv_cudaoptflow;opencv_cudaobjdetect;opencv_cudalegacy;opencv_cudaimgproc;opencv_cudafilters;opencv_cudafeatures2d;opencv_cudacodec;opencv_cudabgsegm;opencv_cudaarithm;opencv_core;opencv_calib3d
Problem : Catkin_LIB including
But I find my package still do not using opencv with cuda .
Now I found my $(catkin_LIBRARIES) including ros-kinetic-opencv3 lib.( This is necessary for the cv_bridge ) This is my ${catkin_INCLUDE_DIRS}. /opt/ros/kinetic/include;/opt/ros/kinetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp;/opt/ros/kinetic/include/opencv-3.2.0-dev;/opt/ros/kinetic/include/opencv-3.2.0-dev/opencv;/usr/include
Let me show some part of my CmakeLists.
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
include_directories( include ${catkin_INCLUDE_DIRS} )
...
target_link_libraries(my_function ${OpenCV_LIBS} ${catkin_LIBRARIES}) # this do not wrok
target_link_libraries(my_gpu_function ${OpenCV_LIBS} ) # this work
"my_function" linked with ${catkin_LIBRARIES} can not use gpu, on the other hand "my_gpu_function" linked only with ${OpenCV_LIBS} does. So I assume catkin_LIB have something to do with this problem.
Updated in 2017 Oct 13: test project
I found excluding every library named opencv from catkin_libraries do works.
I put on my sample project on here. https://github.com/YoshiRi/ros_opencv...
This mean adding any of opencv3.2 in ros package cause the linker to lose cuda opencv function. Fortunately cv_bridge and image_transprot is safe to include, so I can build ros project but I feel very unease about this. Any one has any knowledge about this phenomena?
Question
How can I use both opencv cuda and cv_bridge and any other ros opencv related package in the same time in more better way?
Thank you.