Ubuntu18.04 ros-melodic opencv版本冲突问题解决

原链接:https://blog.csdn.net/Shushan1/article/details/116588614

问题描述

ros自带的opencv版本和自己安装的opencv版本冲突导致如下报错
在这里插入图片描述

解决办法

修改cv_bridge指定的opencv版本

sudo gedit /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake

修改如下两个地方

#if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
if(NOT "include;/usr/local/include/opencv;/usr/local/include/opencv2 " STREQUAL " ")
  set(cv_bridge_INCLUDE_DIRS "")
  #set(_include_dirs "include;/usr/include;/usr/include/opencv")
  set(_include_dirs "include;/usr/local/lib;/usr/local/include/opencv;/usr/local/include/opencv2;/usr/local/include;/usr/include")

这里注意改成自己的版本

#set(libraries "cv_bridge;/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.3.2.0")
set(libraries "cv_bridge;/usr/local/lib/libopencv_core.so.3.4.16;/usr/local/lib/libopencv_imgproc.so.3.4.16;/usr/local/lib/libopencv_imgcodecs.so.3.4.16")

然后重新catkin_make即可

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