ROS中的OpenCv
ROS 在kinetic版本中自带了 OpenCV3,通过 ros-kinetic-opencv3安装
。在目录 /opt/ros/kinetic/include/opencv-3.1.0-dev
中。
在ROS中使用自带的OpenCV
头文件如下:
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
CMakeLists.txt改动如下:
set(OpenCV_DIR /opt/ros/kinetic/include/opencv-3.1.0-dev)
find_package(catkin REQUIRED COMPONENTS
roscpp
OpenCV
)
include_directories(
include
${catkin_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(testing
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
CMakeLists.txt文件中如果没有`set(OpenCV_DIR /opt/ros/kinetic/include/opencv-3.1.0-dev)`,将会报错:
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake