ros2的cv_bridge库opencv版本不匹配问题
- 问题:
libopencv_imgcodecs.so.4.2: cannot open shared object file: no such file or directory
-
原因
ros安装的时候默认的opencv版本是4.2,和本地安装的opencv版本不匹配(我的本地安装的是4.5) -
解决方案
单独重新安装cv_bridge库
//下载对应版本的cv_bridge包(我安装的foxy)
$ git clone https://github.com/ros-perception/vision_opencv.git -b foxy
//进入cv_bridge目录,
//修改CMakeLists.txt文件的opencv版本号,
//改成自己本地安装的版本
find_package(OpenCV 4 QUIET // 改成find_package(OpenCV 5 QUIET, 如果是4.X或3.X,不需要更改
COMPONENTS
opencv_core
opencv_imgproc
opencv_imgcodecs
CONFIG
)
//编译的时候指定安装路径(ros2安装的目录下,我的ros2安装目录:/opt/ros/foxy)
$ cd vision_opencv/cv_bridge
$ mkdir build && cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/opt/ros/foxy ..
$ sudo make install
注意:如果安装了anaconda,需要先退出掉当前的anaconda环境,
$ conda deacrtivate env_name,
再在本地环境下安装,
否则会报错(anaconda环境和ros2环境会有冲突).
题
标签:bridge,opencv,版本,安装,cv,ros2 From: https://www.cnblogs.com/iamheying/p/17028586.html