解决Xavier编译ROS工程中cv_bridge找不到的问题

0. 背景:

Jetson 系列Xavier 系统18.04, 刷机自带opencv4.1.1版本,  普通机器安装18.04系统后会自带opencv3.2版本, ROS自18.04 Melodic 不再自带opencv, 依赖系统opencv, 因此ros中cv_bridgeConfig.cmake默认指定opencv路径是 "/usr/include/opencv", 而在Xavier 中不存在这一路径, 只有 "/usr/include/opencv4", 因此当你在Xavier 下编译cv_bridge时会报错如下:

CMake Error at /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake:113 (message):
  Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir,
  which is not found.  It does neither exist as an absolute directory nor in
  '${{prefix}}//usr/include/opencv'.  Check the issue tracker
  'https://github.com/ros-perception/vision_opencv/issues' and consider
  creating a ticket if the problem has not been reported yet.
Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)

 1. 解决方法

网上一搜好多什么更改版本什么的, 可以但比较麻烦, 你可以不用刷机自带的版本, 手动编译安装一个版本, 然后修改ros中cv_bridgeConfig.cmake, 替换默认路径库等, 但安装多个版本很容易导致系统出问题, 其实方法很简单, 只需要下载ros的cv_bridge功能包, 放到需要用到cv_bridge模块的ROS项目工程src中, 这样项目在编译的过程中就会编译系统的opencv4版本, 从而覆盖系统的cv_bridge模块. 删除build和devel内容重新编译项目即可.

可以github去找, 不好下的可以参考百度云链接: https://pan.baidu.com/s/1NvFdSRFhnf-uF1XrdLequw 提取码: tx68

你可能感兴趣的:(ROS,Xavier,cv_bridge,ROS)