Ask Your Question
5

Problem with using opencv_GPU inside ROS

asked 2012-11-01 04:51:15 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi ALl,

I am very new into ROS. I wanted to use GPU support from OpenCv inside ROS platform. But I faced an error where it said ROS opencv is built without CUDA support. The I tried to build myself OpenCv(after downloading from OpenCv website) with CUDA support into the /usr/local . I wanted to test it with a simple code. But EVen though the version I downloaded and built is built with CUDA. My project somehow connects to the CV from ROS-fuerte and gives me an error as below.

OpenCV Error: No GPU support (The library is compiled without CUDA support) in mallocPitch, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1632/modules/core/src/gpumat.cpp, line 749 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1632/modules/core/src/gpumat.cpp:749: error: (-216) The library is compiled without CUDA support in function mallocPitch

I have two questions. I am sure many of you will find it very simple problem. I am unable to understand how I can solve the below problems..

1) How can I use my local copy of OpenCv which I built with CUDA support ? 2) Is it possible to use it also in ROS ignoring the prebuilt openCv in ROS which is without CUDA support ?

regards, Subhasis

edit retag flag offensive close merge delete

Comments

can you use cuda with opencv in ROS? if you can ,would you share your Experience?my mail is goujiaolong@gmail.com thanks a lot .

longzhixi123 gravatar image longzhixi123  ( 2013-04-23 22:57:09 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
7

answered 2012-11-01 23:34:55 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Yes, you can use your custom-built OpenCV instead of those provided by ROS.

Add this line to your .bashrc(or anywhere similarly where you set ROS environments):

export CMAKE_PREFIX_PATH=/usr/local:$CMAKE_PREFIX_PATH

Make sure your CMAKE_PREFIX_PATH is like this(/usr/local is the path prefix where you installed OpenCV):

$ echo $CMAKE_PREFIX_PATH
/usr/local:/opt/ros/fuerte/share/catkin/cmake/Modules:/opt/ros/fuerte

Then add these lines to your CMakelists.txt:

find_package(OpenCV 2.4 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
...
target_link_libraries(YOUR_TARGET ${OpenCV_LIBS})

Start a new term and remove old build/* files, then make again. In this case CMake can find your installed OpenCV first.

edit flag offensive delete link more

Comments

Hi K Chen, I've followed your steps however I am still having some issues with my program still being compiled with OPENCV2.4.2. I trying to debug this with no success. I checked the pkg that CMAKE is grabbing which is OPENCV2.3.1 which is what I want but when I compile and run I get 2.4.2 errors.

Rookdroid gravatar image Rookdroid  ( 2013-03-13 04:18:11 -0500 )edit

Which version of OpenCV do you want? ROS Fuerte provides OpenCV 2.4.x and if you want to use other versions or your custom built libs, refer to the instruction above and change the version xx in find_package(OpenCV xx)

K Chen gravatar image K Chen  ( 2013-03-14 03:20:54 -0500 )edit

Hi K Chen,I want to know what should be changed in your sugestions with ROS-electric? thanks

746666288 gravatar image 746666288  ( 2013-03-24 20:54:48 -0500 )edit

I am not sure if this works for ROS Electric, but the $CMAKE_PREFIX_PATH is available for all current CMake versions, so you can give it a try. And if you have a rosdep in your manifest.xml, don't forget to remove it, or it can be confusing if you depends on two OpenCV version.

K Chen gravatar image K Chen  ( 2013-03-31 16:22:25 -0500 )edit

thanks .your comments are very useful.haha

746666288 gravatar image 746666288  ( 2013-03-31 16:33:49 -0500 )edit

Hi, I am also trying to use GPU enabled OpenCV with ROS and I tried this method. I am able to compile the code but when starting the node with rosrun, it tries to get my kinetic opencv which is not GPU enabled and throws CUDA not enabled excetion. Any solutions for that?

naveenT1010 gravatar image naveenT1010  ( 2017-05-27 20:30:38 -0500 )edit
0

answered 2012-11-04 13:42:36 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I suffered from the same problem. The answer seems helpful. Thank you :)

However, i want to use c/c++ codes with CUDA separately from ROS. What can i do?

Actually, I installed opencv with CUDA support into the /usr/local. and I already tested some sampled codes provided with opencv installation files. Then, I installed ROS fuerte. After ROS installation, I got errors when I tried to execute some codes I already tested. Error messages are followings, OpenCV Error: No GPU support (The library is compiled without CUDA support) in getDevice, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1624/modules/core/src/gpumat.cpp, line 182 /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1624/modules/core/src/gpumat.cpp:182: error: (-216) The library is compiled without CUDA support in function getDevice

regards, jhlim

edit flag offensive delete link more

Comments

The solution provided above can be applied to any CMake projects. Your problem arise because installing ROS will set $CMAKE_PREFIX_PATH and after that your project will first find the opencv package provided with ROS, not the one you built. Just add "/usr/local" to $CMAKE_PREFIX_PATH and build again

K Chen gravatar image K Chen  ( 2012-11-24 01:20:44 -0500 )edit
0

answered 2012-12-02 12:16:51 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi

I also have the same issue, but I use qmake insted of cmake. Maybe someone khnow how make the same thing with it. I mean make local libraries recognies before ROS libraries.

I made the modification in the .bashrc file. For being sur I close my IDE. Open a new bash window, restart my IDE on my project, clean all, and recompile. But even with that the linker look the opencv's plugins (.so), in the ROS stack.

Regards, Teddy

edit flag offensive delete link more

Comments

I don't recommend qmake because ROS uses CMake to construct projects. Meanwhile, converting from qmake project to CMake is easy, see this: http://qt-project.org/quarterly/view/using_cmake_to_build_qt_projects

K Chen gravatar image K Chen  ( 2012-12-06 19:25:06 -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

2 followers

Stats

Asked: 2012-11-01 04:51:15 -0500

Seen: 3,776 times

Last updated: Dec 02 '12