简体   繁体   English

如何将 OpenCV 4 与 ROS (cv_bridge) 链接

[英]How to link OpenCV 4 with ROS (cv_bridge)

I'm using OpenCV in ROS Melodic, I need now to use cv::dnn (deep neural network), which is incluced in OpenCV 4, which I have installed, and set it to my CMakeLists.txt like this:我在 ROS Melodic 中使用 OpenCV,我现在需要使用 cv::dnn(深度神经网络),它包含在我已安装的 OpenCV 4 中,并将其设置为我的 CMakeLists.txt,如下所示:

find_package(OpenCV 4 REQUIRED )

this is warning that I'm getting when I do command: catkin_make in my ros workspace:这是我在 ros 工作区中执行命令时收到的警告: catkin_make

/usr/bin/ld: warning: libopencv_imgcodecs.so.3.2, needed by /opt/ros/melodic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.4.1 /usr/bin/ld:警告:/opt/ros/melodic/lib/libcv_bridge.so 需要的 libopencv_imgcodecs.so.3.2,可能与 libopencv_imgcodecs.so.4.1 冲突

I ignored that but I can't rosrun any node with opencv right now.我忽略了这一点,但我现在无法使用 opencv 运行任何节点。

Can someone help me how to set OpenCV 4 in cv_bridge (ROS melodic system)?有人可以帮我如何在 cv_bridge(ROS 旋律系统)中设置 OpenCV 4 吗?

Thanks in advance.提前致谢。 Best Regards, Jovan.最好的问候,约万。

There is an opencv shipped with ROS which is used for image related stuff.有一个 opencv 随 ROS 一起提供,用于图像相关的东西。 Some ROS packages such as cv_bridge, image_geometry etc. use this opencv by default.一些ROS包如cv_bridge、image_geometry等默认使用这个opencv。 This is the reason you get segmentation fault because different opencv versions are storing image in different formats.这就是您出现分段错误的原因,因为不同的 opencv 版本以不同的格式存储图像。

If you want to use a custom opencv within your node, you must include these packages in your working directory and compile them also.如果您想在您的节点中使用自定义 opencv,您必须将这些包包含在您的工作目录中并同时编译它们。 For example, you must includecv_bridge source code in your node's cmakelist.例如,您必须在节点的 cmakelist 中包含cv_bridge 源代码

A simple solution is to download a suitable version of vision_opencv from https://github.com/ros-perception/vision_opencv/releases .一个简单的解决方案是从https://github.com/ros-perception/vision_opencv/releases下载合适版本的 vision_opencv。 Then extract the contents (containing some packages cv_bridge image_geometry opencv_tests vision_opencv ) to a folder called vision_opencv of your src folder in your catkin workspace.然后将内容(包含一些包cv_bridge image_geometry opencv_tests vision_opencv )提取到 catkin 工作区中src文件夹的vision_opencv文件夹中。

Now catkin_make or catkin build your workspace and the necessary ros opencv packages will compile and link against the local vision_opencv folder.现在catkin_make或 catkin catkin build您的工作区,必要的 ros opencv 包将编译并链接到本地vision_opencv文件夹。 You might need to clean your workspace before that.在此之前,您可能需要清理工作区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ROS节点中OpenCV 4和cv_bridge之间的冲突 - Conflict between OpenCV 4 and cv_bridge in ROS Node 为什么cv_bridge在ROS Melodic中使用OpenCV 3.2? - Why cv_bridge uses OpenCV 3.2 in ROS Melodic? ROS问题:如何用opencv4正确编译自定义cv_bridge - ROS question: How to compile custom cv_bridge with opencv4 correctly 使用cv_bridge(ROS indigo)和OpenCV 3时出现分段错误(核心转储) - Segmentation fault (core dumped) when using cv_bridge(ROS indigo) and OpenCV 3 无法将cv_bridge与ROS Kinetic和Python3一起使用 - Unable to use cv_bridge with ROS Kinetic and Python3 ROS cv_bridge::toCvCopy 因分段错误而失败 - ROS cv_bridge::toCvCopy fails with segmentation fault 访问cv_ptr-> image时,类中的ROS cv_bridge导致segfault - ROS cv_bridge in a class leads to segfault when cv_ptr->image is accessed 使用 ROS Kinetic 和 Python3 构建 cv_bridge 包而忽略 Cmake 参数 - Building cv_bridge Package with ROS Kinetic and Python3 ignoring Cmake Arguments ROS 包 cv_bridge 和 libopencv4tegra 无法在 Tegra TK1 上同时安装 - ROS package cv_bridge and libopencv4tegra can not install at the same time on Tegra TK1 如何使用catkin将OpenCV 3.4.5 dnn模块与自定义cv_bridge链接? 错误:未定义的引用cv :: dnn:experimental_dnn_v2 :: Net :: Net() - How to linked OpenCV 3.4.5 dnn module with custom cv_bridge using catkin? Error: undefined reference cv::dnn:experimental_dnn_v2::Net::Net()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM