https://answers.ros.org/question/242376/having-trouble-using-cuda-enabled-opencv-with-kinetic/
Hello everyone.
I started a new install of ROS Kinetic, and I was hoping to use a few CUDA features from OpenCV. I have successfully compiled and tested CUDA and OpenCV (which is installed in /usr/local), but I am having trouble using my OpenCV instead of the ros-kinetic-opencv3
package.
I have tried adding /usr/local to the front of my CMAKE_PREFIX_PATH, as well renaming the opencv pkgconfig file in /opt/ros/lib/pkconfig. However I still get the below error, indicating that I am building against the ROS OpenCv.
OpenCV Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file /tmp/binarydeb/ros-kinetic-opencv3-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp, line 97 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/binarydeb/ros-kinetic-opencv3-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:97: error: (-216) The library is compiled without CUDA support in function throw_no_cuda
Any ideas?
Comments
It looks like its loading the wrong library at runtime; this is usually controlled by the system library search paths (ldconfig) and LD_LIBRARY_PATH
ahendrix ( Aug 25 '16 )
LD_LIBRARY_PATH looks like /usr/local/lib:/home/user/catkin_ws/devel/lib:/opt/ros/kinetic/lib
shouldn't it be pulling from /usr/local/lib where OpenCV is first if that was the case?
daniel_dsouza ( Aug 25 '16 )
if I manually run the CMakeLists.txt file, then the code build and executes correctly. However using catkin_make give different results?
daniel_dsouza ( Aug 26 '16 )
@daniel_dsouza, how did you run it manually? Just CMake .. and make?
ashwath1993 ( Jun 15 '17 )
I believe so. Do you have a Github link to your code? I can try to compile it myself.
daniel_dsouza ( Jun 15 '17 )
https://github.com/ashnarayan13/stere... this is the code.
ashwath1993 ( Jun 16 '17 )
Could you please link your entire ros package? Until then, look at this (working) example https://github.com/daniel-dsouza/solid-succotash
daniel_dsouza ( Jun 16 '17 )
@daniel_dsouza I have added the entire projecct on git. I will look into your project as well! Thanks!
ashwath1993 ( Jun 16 '17 )
see more comments
1 Answer
Sort by » oldest newest most voted
5
daniel_dsouza
183 ●9 ●11 ●16
Hello previous me,
So you have the opencv3 package installed, which provides libraries in /opt/ros/kinetic/lib,
and you also have OpenCV compiled from source, installed to usr/local
. The trick is to tell catkin to use the libraries from usr/local
.
By default, catkin is hardwired to look for packages in your workspace, then in /opt/ros/kinetic
. CMake by itself will use the libraries in /usr/local
. I tried to prioritize /usr/local
by modifying the CMAKE_PREFIX_PATH
environment variable, as suggested in pre kinetic posts, but no luck.
So if I cannot modify catkin itself, I should to explicitly tell CMake which OpenCV to use. I had to change my declaration from
find_package(OpenCV REQUIRED)
to
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
So that will pull in the correct libraries. If another package is built that requires OpenCV, catkin will also pull in the wrong dependencies. Mixed dependencies is a bad thing. So you have to add the modified OpenCV configuration to any other packages that require OpenCV. This includes the vision_opencv
package that provides cv_bridge
.
UPDATE 10/12/2017: Please see my fork of vision_opencv for the necessary changes and my cvTest example package. In the example, I demonstrate the use of my custom version of OpenCV 3.3 build with CUDA 8.