[英]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.