将ROS Noetic链接到OpenCV的构建

发布于 2025-02-09 01:43:10 字数 1241 浏览 2 评论 0原文

我正在写一个使用OpenCV和Sift的ROS节点(ROS Noetic,Ubuntu 20.04)。 从OPENCV版本4开始,SIFT算法是 opencv_contrib package的一部分。 在我的ROS节点中,我想使用ROS包CV_Bridge,在OpenCV映像格式和ROS Image传感器消息之间转换。

我的理解是,

  1. 仅当与源中的OpenCV一起构建此类软件包时,OPENCV_CONTRIB软件包中的代码才可用。
  2. CV_Bridge取决于OpenCV的Ubuntu软件包版本,libopencv-dev。

我目前都已经安装了(Ubuntu软件包和从源中收集的版本),并且我试图使我的节点取决于源代码编译,以便使用非免费算法。 为此,我的过程是(使用其他模块编译OpenCV和OpenCV_ENABLE_NONFREE = ON之后)添加到CMAKELISTS.TXT.txt以下行:

find_package(OpenCV PATHS .../opencv-4.5.4/cmake)
include_directories(include ${catkin_INCLUDE_DIRS} .../opencv-4.5.4/include)
link_directories(.../opencv-4.5.4/lib)
add_executable(...)
target_link_libraries(nodeName ${catkin_LIBRARIES} .../opencv-4.5.4/lib)

为了将我的代码链接到编译版本的OpenCV版本。但是,当我尝试使用catkin build进行构建时,我会得到:

In file included from [...]:
[...]/markerDetection.h:8:10: fatal error: opencv2/xfeatures2d.hpp: No such file or directory
    8 | #include <opencv2/xfeatures2d.hpp>

我怀疑ROS试图链接到我通过软件包管理器安装的版本,实际上它没有opencv2 /xfeatures2d.hpp库。 我是否在cmakelists.txt中设置了错误的选项?我想做的甚至可能做的事情吗?

I am writing a ROS node which uses OpenCV and SIFT (ROS Noetic, Ubuntu 20.04).
As of OpenCV version 4, the SIFT algorithm is part of the opencv_contrib package.
Within my ROS node, I want to use the ROS package cv_bridge, to convert between the OpenCV image format and ROS image sensor messages.

My understanding is that

  1. Code in the opencv_contrib package is only usable if such package is built together with OpenCV from source.
  2. cv_bridge depends on the Ubuntu package version of OpenCV, libopencv-dev.

I currently have both installed (the Ubuntu package and the version compiled from source) and I am trying to have my node depend on the source-compiled one, in order to use the non-free algorithms.
My procedure in order to do this is (after compiling OpenCV with the additional modules and OPENCV_ENABLE_NONFREE=ON) adding to the CMakeLists.txt of my package the following lines:

find_package(OpenCV PATHS .../opencv-4.5.4/cmake)
include_directories(include ${catkin_INCLUDE_DIRS} .../opencv-4.5.4/include)
link_directories(.../opencv-4.5.4/lib)
add_executable(...)
target_link_libraries(nodeName ${catkin_LIBRARIES} .../opencv-4.5.4/lib)

in order to link my code to the compiled version of OpenCV. However, when I try to build it with catkin build I obtain:

In file included from [...]:
[...]/markerDetection.h:8:10: fatal error: opencv2/xfeatures2d.hpp: No such file or directory
    8 | #include <opencv2/xfeatures2d.hpp>

I suspect that ROS is trying to link to the version I installed through the package manager, which in fact does not have the opencv2/xfeatures2d.hpp library.
Am I setting the wrong options in CMakeLists.txt? Is what I am trying to do even possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文