Skip to Content
ROS Programming: Building Powerful Robots
book

ROS Programming: Building Powerful Robots

by Anil Mahtani, Luis Sanchez, Enrique Fernandez, Aaron Martinez, Lentin Joseph
March 2018
Intermediate to advanced content levelIntermediate to advanced
1396 pages
42h 14m
English
Packt Publishing
Content preview from ROS Programming: Building Powerful Robots

Using OpenCV in ROS

ROS uses the standalone OpenCV library installed on your system. However, you must specify a build and run dependency with an opencv2 package in the package.xml file:

<build_depend>opencv2</build_depend> 
<run_depend>opencv2</run_depend> 

In CMakeLists.xml, we have to insert the following lines:

find_package(OpenCV) 
include_directories(${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS}) 

Then, for each library or executable that uses OpenCV, we must add ${OpenCV_LIBS} to target_link_libraries (see CMakeLists.txt provided for the chapter5_tutorials package).

In our node .cpp file, we include any of the OpenCV libraries we need. For example, for highgui.hpp, we use the following line:

#include <opencv2/highgui/highgui.hpp> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Robots with ROS

Programming Robots with ROS

Morgan Quigley, Brian Gerkey, William D. Smart
Machine Learning Design Patterns

Machine Learning Design Patterns

Valliappa Lakshmanan, Sara Robinson, Michael Munn

Publisher Resources

ISBN: 9781788627436Supplemental Content