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

How do I Install OpenCV2

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

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 ( http://wiki.ros.org/opencv2 ). Any help would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Hope this helps

edit flag offensive delete link more

Comments

1) Would something like the code below work?

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

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

K. Zeng gravatar image K. Zeng  ( 2014-10-08 12:40:34 -0500 )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 -0500 )edit
1

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

find_package(OpenCV REQUIRED)
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
)

...

K. Zeng gravatar image K. Zeng  ( 2014-10-09 13:30:55 -0500 )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 -0500 )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 -0500 )edit

I have not tested it under indigo, yet. Sorry

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

Question Tools

1 follower

Stats

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

Seen: 4,344 times

Last updated: Oct 07 '14