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

add opencv to indigo

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

hsoltani gravatar image

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

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
5

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

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

Comments

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 -0500 )edit
3

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

Mehdi. gravatar image

You should install opencv by yourself on your computer, the easiest way is to clone this to your computer https://github.com/jayrambhia/Install...

git clone https://github.com/jayrambhia/Install-OpenCV.git

Then run the ubuntu/opencv_install.sh

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)
include_directories(${OpenCV_INCLUDE_DIRS})

and

target_link_libraries(your_cpp_node ${OpenCV_LIBS})

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

edit flag offensive delete link more

Comments

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 -0500 )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 -0500 )edit
1

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 -0500 )edit

Thanks for the update @fergs

Mehdi. gravatar image Mehdi.  ( 2014-07-07 19:12:07 -0500 )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 -0500 )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 -0500 )edit
1

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

Mehdi. gravatar image Mehdi.  ( 2015-04-23 05:11:55 -0500 )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 -0500 )edit
0

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

edit flag offensive delete link more

Comments

That tutorial uses rosmake.

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

Question Tools

2 followers

Stats

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

Seen: 14,576 times

Last updated: Nov 03 '16