【问题标题】:How to use OpenCV 4 with ROS?如何将 OpenCV 4 与 ROS 一起使用?
【发布时间】:2020-07-05 08:07:59
【问题描述】:

我正在尝试在 Windows 上使用 OpenCV 4.2.0 运行 ROS Melodic 我的 CMakeLists 有什么问题?我已将 OpenCV 添加到我的系统路径中,但 Catkin_make 总是出现此错误:

Could not find a configuration file for package "OpenCV" that is compatible
  with requested version "4.2.0".
  The following configuration files were considered but not accepted:
    C:/opt/rosdeps/x64/CMake/OpenCVConfig.cmake, version: 3.4.1

它找到的版本是随 ROS 旋律发行版提供的 OpenCV。如何更改 CMake 搜索的位置?

这是我的 CMake:

cmake_minimum_required(VERSION 2.8.3)
project(nav_ross)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
  cv_bridge
  image_transport
  pcl_ros
  sensor_msgs
  visualization_msgs
  dynamic_reconfigure
  geometry_msgs
)

find_package(OpenCV 4.2.0 REQUIRED)

add_message_files(
   FILES
   nav_msg.msg
 )

 generate_messages(
   DEPENDENCIES
   std_msgs
   visualization_msgs
   geometry_msgs
 )

 generate_dynamic_reconfigure_options(
    cfg/post-process-config.cfg
 )

catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime cv_bridge image_transport pcl_ros sensor_msgs visualization_msgs geometry_msgs
)

include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ../../cpp
cfg/cpp/nav_ross
)

add_library(iasdk_static STATIC ../../cpp/radarclient.cpp ../../cpp/tcpradarclient.cpp ../../cpp/tcpsocket.cpp ../../cpp/timer.cpp ../../cpp/threadedclass.cpp)

add_executable(Movement-Detector Movement-Detector.cpp)
target_link_libraries(Movement-Detector ${catkin_LIBRARIES} ${OpenCV_LIBS})
add_dependencies(Movement-Detector nav_ross_generate_messages_cpp)

add_executable(talker1 talker1.cpp)
target_link_libraries(talker1 ${catkin_LIBRARIES} ${OpenCV_LIBS} iasdk_static)
add_dependencies(talker1 nav_ross_generate_messages_cpp ${devel2_pkg_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

add_executable(Mobile_Platform Mobile_Platform.cpp)
target_link_libraries(Mobile_Platform ${catkin_LIBRARIES} ${OpenCV_LIBS} iasdk_static)
add_dependencies(Mobile_Platform nav_ross_generate_messages_cpp ${devel2_pkg_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

【问题讨论】:

    标签: opencv makefile cmake ros


    【解决方案1】:

    尝试告诉 CMake 你的 OpenCV 在哪里,也许它会寻找第一个,如果找到要使用的力量。

    find_package(OpenCV REQUIRED PATHS Path/to/OpenCV NO_DEFAULT_PATH) 
    

    【讨论】:

    • 这一半工作了 - 现在它找到了包,但是我收到一个错误:错误 C2039: 'warpPolar': is not a member of 'cv'... 它正在查看 rosdeps ros 附带的 opencv 3.4.1 版本。
    • 您确定可以通过 cv_bride 使用“外部”OpenCV 吗?我不确定是否可以,请检查它
    猜你喜欢
    • 2020-03-17
    • 1970-01-01
    • 2014-04-27
    • 2015-11-27
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多