Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将OpenCV 4与ROS一起使用?_Opencv_Makefile_Cmake_Ros - Fatal编程技术网

如何将OpenCV 4与ROS一起使用?

如何将OpenCV 4与ROS一起使用?,opencv,makefile,cmake,ros,Opencv,Makefile,Cmake,Ros,我正在尝试在windows上使用OpenCV 4.2.0运行ROS Melodic我的CmakeList有什么问题?我已将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

我正在尝试在windows上使用OpenCV 4.2.0运行ROS Melodic我的CmakeList有什么问题?我已将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 melodic发行版附带的OpenCV。如何更改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})

试着告诉CMake你的OpenCV在哪里,也许它会寻找第一个,如果找到可以使用的力

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

这半部分工作正常-现在它找到了包的名称,但是我得到了一个错误:错误C2039:“warpPolar”:不是“cv”的成员。。。它正在rosdeps中查看ros附带的opencv 3.4.1版本。您确定可以使用cv_bride使用“外部”opencv吗?我不确定是否可能,请检查一下