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

How do I Install OpenCV2

asked 2014-10-07 14:38:07 -0600

K. Zeng gravatar image

I'm trying to get image_transport to work, but when I tried both roscreate-pkg and catkin_create_kpg, I always get the error along the lines of "the dependency opencv2 is missing". I used locate for opencv2 and found opencv2 under /usr/include. How do I get it working with ROS Indigo? Do I still need vision_opencv and all the other libopencv* packages like described in this page ( ). Any help would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-10-07 17:18:49 -0600

ct2034 gravatar image
  • You have to declare opencv2 as an external dependency in your CMakeLists.txt. Similar to eigen and opencv in this example:
  • You will have to add opencv2 also to the target_link_libraries (in CMakeLists.txt)

Hope this helps

edit flag offensive delete link more


1) Would something like the code below work?

  INCLUDE_DIRS include
  LIBRARIES image_mover
  CATKIN_DEPENDS cv_bridge image_transport 
  DEPENDS system_lib opencv2

2) I don't have a .cpp file in the package's src folder yet. Should I write that out first?

K. Zeng gravatar image K. Zeng  ( 2014-10-08 12:32:36 -0600 )edit

UPDATE: What I did in the above comment didn't work.

K. Zeng gravatar image K. Zeng  ( 2014-10-08 12:40:34 -0600 )edit

What is not working? Which steps are you taking? What is the output of catkin_make?

ct2034 gravatar image ct2034  ( 2014-10-08 16:24:43 -0600 )edit

Never mind. What I ended up doing was the following:

find_package(OpenCV REQUIRED)
find_package(catkin REQUIRED COMPONENTS


K. Zeng gravatar image K. Zeng  ( 2014-10-09 13:30:55 -0600 )edit


target_link_libraries(publisher ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
target_link_libraries(publisher ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})
target_link_libraries(subscriber ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})

I also removed opencv and opencv2 from package.xml.

K. Zeng gravatar image K. Zeng  ( 2014-10-09 13:32:22 -0600 )edit

hey, how did you setup opencv with ros indigo? i have a lot of problem with this. What did you put in you Cmakelist file and xml file

dmngu9 gravatar image dmngu9  ( 2015-05-08 23:51:43 -0600 )edit

I have not tested it under indigo, yet. Sorry

ct2034 gravatar image ct2034  ( 2015-09-14 01:57:41 -0600 )edit

Question Tools

1 follower


Asked: 2014-10-07 14:38:07 -0600

Seen: 4,302 times

Last updated: Oct 07 '14