ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to add GPU support in ROS opencv

asked 2012-02-23 20:11:25 -0500

brice rebsamen gravatar image

Sorry for insisting on the topic (see but I still think this is relevant to ROS.

In Ubuntu 11.10, ros-electric-vision-opencv depends on libopencv2.3-dev (= 2.3.1+svn6514+branch23-9~oneiric).

It seems to me that the libopencv package does not provide GPU support out of the box, and to obtain GPU support one has to recompile OpenCV from source with the WITH_CUDA option. Not exactly easy, but anyway... assuming success in the later, how to then install ros-electric-vision-opencv and make sure my code (HOG) will run the GPU?

If ros-electric-vision-opencv depended on libopencv2.3-dev with a more flexible version number I guess I would try building a package to replace the 2.3.1+svn6514+branch23-9~oneiric package. Or am I missing something here?

Sorry if I am off topic again, but I really need the info...

edit retag flag offensive close merge delete


hello,i want to use surfgpu with ros, is it possible ? thanks a lot

longzhixi123 gravatar image longzhixi123  ( 2013-05-06 17:03:58 -0500 )edit

3 Answers

Sort by » oldest newest most voted

answered 2012-02-24 02:11:29 -0500

What keeps you from using a (userspace-)local installation of opencv and compile and link against that? If you omit opencv from your manifest, the "original" cv install shouldn't even appear in your compiler-flags. Then you can just add your local version of opencv in manifest.xml

edit flag offensive delete link more


first of all I am part of a team and not everybody is GPU enabled. So if I point my manifest to a local install then it will create problem for the rest of the team. Maybe there is a hack, such as using conditional rules, etc...

brice rebsamen gravatar image brice rebsamen  ( 2012-03-11 16:15:05 -0500 )edit

Second, making sure opencv is not in any of my dependencies directly or indirectly is going to be tough as I need to use cv_bridge too. I was thinking that I could attempt to rebuild the opencv package from source but the source package is not available from the ROS repo. Could it be made available?

brice rebsamen gravatar image brice rebsamen  ( 2012-03-11 16:18:01 -0500 )edit

The source is linked to from the wiki page.

tfoote gravatar image tfoote  ( 2012-04-19 18:15:23 -0500 )edit

answered 2012-02-24 04:50:10 -0500

tfoote gravatar image

We cannnot reliably release opencv with looser version dependencies due to often changing ABI compatability, and sometimes API compatability changes, like the ones you're looking for when there are binary packages built on top of the opencv release. I suggest you look at doing what @Felix Endres suggests of creating a source package that you layer on top, and make sure the the binary install of opencv is not in any of your dependencies directly or indirectly.

edit flag offensive delete link more


what about ? Getting rid of the binary vision_opencv and installing it from source, with the latest opencv? could somebody explain the versioncontrol tag part?

brice rebsamen gravatar image brice rebsamen  ( 2012-02-26 14:48:38 -0500 )edit

answered 2014-03-26 10:53:46 -0500

Ok here is what I did .. first I installed opencv with the flags for GPU set, that is, with -D WITH_CUDA=ON . Now I renamed the opencv package config files in /opt/ros/groovy/lib/pkgconfig to something else eg.

opencv.pc to opencv.pc.disable

opencv2.pc to opencv2.pc.disable

I did this so that now when you build the vision_opencv (in the overlay/workspace) the package manager builds your cv_bridge (contained in vision_opencv) stuff against your gpu enabled opencv and not the ros opencv.

Just source the overlay and you're ready to go.

This is a quick hack and might save you a lot of time.


edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-02-23 20:11:25 -0500

Seen: 4,431 times

Last updated: Mar 26 '14