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

add opencv to indigo

asked 2014-07-07 02:16:27 -0600

hsoltani gravatar image

updated 2014-07-07 14:37:35 -0600

The Opencv packages aren't built in the ROS Indigo anymore. So what should I do if I want to add opencv2?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2014-07-07 08:30:44 -0600

Note that for compatibility with Hydro and general simplicity it is recommended to use cv_bridge as a dependency to pull in opencv for Indigo packages (a bit hacky though, as this pulls in other related packages). See discussion on github and Indigo migration guide on OpenCV.

edit flag offensive delete link more


Given the OP asks about Indigo, I think this looks more appropriate ROS-way and should be chosen as the answer IMO.

130s gravatar image 130s  ( 2014-07-09 17:30:30 -0600 )edit

answered 2014-07-07 03:23:38 -0600

Mehdi. gravatar image

You should install opencv by yourself on your computer, the easiest way is to clone this to your computer

git clone

Then run the ubuntu/

Now in your ros package:

In the manifest.xml add this line

<rosdep name="opencv2"/>

you also need to include these lines in your CMakeFiles.txt

find_package(OpenCV REQUIRED)


target_link_libraries(your_cpp_node ${OpenCV_LIBS})

for linking the libraries to the nodes written in c++.

edit flag offensive delete link more


Thanks for your reply. I do the same and add the lines except the last line (target_link_libraries) since the package is written in python. The package is built correctly but I get following error when using roslaunch for running it: cv_image = self.bridge.imgmsg_to_cv(data, "bgr8") AttributeError: CvBridge instance has no attribute 'imgmsg_to_cv'

hsoltani gravatar image hsoltani  ( 2014-07-07 04:32:08 -0600 )edit

This is not the right way to do it -- the opencv2 rosdep will slowly be going away, replaced by the libopencv-dev rosdep which uses the system OpenCV rather than the one built for ROS. On ubuntu, all you should have to do is "sudo apt-get install libopencv-dev".

fergs gravatar image fergs  ( 2014-07-07 14:49:19 -0600 )edit

Further, if you are using debians for cv_bridge, etc, you should almost certainly be using debians for OpenCV.

fergs gravatar image fergs  ( 2014-07-07 14:49:50 -0600 )edit

Thanks for the update @fergs

Mehdi. gravatar image Mehdi.  ( 2014-07-07 19:12:07 -0600 )edit

@fergs sudo apt-get install libopencv-dev caused me a lot of troubles, deleting it and compiling OpenCV by myself solved them

Mehdi. gravatar image Mehdi.  ( 2014-08-01 03:54:58 -0600 )edit

Hi, I'm stuck in a similar situation. My node is a Python node, and not a CPP node. In this case, how do I proceed with target link libraries?

voladoddi gravatar image voladoddi  ( 2015-04-22 16:41:14 -0600 )edit

@voladoddi, no need to link, in your python script just write "import cv2"

Mehdi. gravatar image Mehdi.  ( 2015-04-23 05:11:55 -0600 )edit

Yes, thanks! it was already there I just needed to remove the link libraries line entirely. It makes sense now.

voladoddi gravatar image voladoddi  ( 2015-04-23 12:40:10 -0600 )edit

answered 2016-02-10 01:31:37 -0600

edit flag offensive delete link more


That tutorial uses rosmake.

andrestoga gravatar image andrestoga  ( 2016-04-07 16:50:56 -0600 )edit

Question Tools



Asked: 2014-07-07 02:16:27 -0600

Seen: 14,549 times

Last updated: Nov 03 '16