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

最近在ros-melodic上使用find_object_2d功能包,但是运行find_object_2d节点,并订阅/usb_cam/image_raw话题时,会出现闪退报错,即运行如下命令:

rosrun find_object_2d find_object_2d image:=/usb_cam/image_raw 

然后出现闪退报错如下:
OpenCV Error: Assertion failed (tlsSlots.size() > slotIdx) in releaseSlot, file /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/system.cpp, line 1092 terminate called after throwing an instance of ‘cv::Exception’ what(): /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/system.cpp:1092: error: (-215) tlsSlots.size() > slotIdx in function releaseSlot

这个问题是由于我ubuntu安装的版本是3.4.13版本,而ros自带的opencv版本是3.2.0的,因此版本有冲突,需要将cv_bridge的opencv版本改成自己的opencv版本,操作如下:

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

然后修改以下两个地方:
Ubuntu18.04 ros-melodic opencv版本冲突问题解决_第1张图片
以及
在这里插入图片描述
最后重新进入工作空间catkin_make即可

参考:https://blog.csdn.net/bigdog_1027/article/details/79092263

你可能感兴趣的:(linux,opencv,ros,melodic,find_object)