ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to get OpenCV 4 working with ROS Melodic?

asked 2020-03-24 13:21:53 -0500

wgengland gravatar image

updated 2020-03-24 13:41:20 -0500

gvdhoorn gravatar image

I'm trying to run ROS Melodic with Opencv 4.2.0 on windows What is wrong with my CMAKELISTS? I have added opencv to my system path, but Catkin_make always gives this error:

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

The version it finds is the opencv shipped with ROS melodic distribution. How do I change where CMAKE searches?

This is my 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})
edit retag flag offensive close merge delete

Comments

1

A quick comment: please realise this is not really something ROS or Catkin specific, but very likely a generic CMake question.

Reason I write this is that as such, you could post this question on fora dedicated to CMake support, which most likely have a much more active user community on Windows. This means a higher chance of getting answers, and a higher chance of finding someone (or someones) with experience with CMake on Windows.

Not saying you can't get any answers here, but it seems inefficient to limit your query (and search space) to "ROS CMake Windows" while it's really "CMake Windows".

gvdhoorn gravatar image gvdhoorn  ( 2020-03-24 13:44:04 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-03-24 21:36:19 -0500

Your CMake and error are pretty clear:

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

It is looking for 4.2.0 but found your installed version 3.4.1.

In your CMakeLists:

find_package(OpenCV 4.2.0 REQUIRED)

It requires this version. You have a version mismatch.

edit flag offensive delete link more

Comments

Thanks for the help, but I do have this version installed. It seems ROS distro also comes with 3.4.1 and the find package command finds this old version, not the new one.

wgengland gravatar image wgengland  ( 2020-03-25 03:56:44 -0500 )edit

Are you sure its installed? How are you sure? Verify that first please.

stevemacenski gravatar image stevemacenski  ( 2020-03-25 10:41:34 -0500 )edit

Yes I'm sure - it's very confusing. I can see the directory it has installed: C:\opencv with config.cmake containing:

set(OpenCV_VERSION 4.2.0) set(PACKAGE_VERSION ${OpenCV_VERSION})

set(PACKAGE_VERSION_EXACT False) set(PACKAGE_VERSION_COMPATIBLE False)

if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT True) set(PACKAGE_VERSION_COMPATIBLE True) endif()

if(PACKAGE_FIND_VERSION_MAJOR EQUAL 4 AND PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) set(PACKAGE_VERSION_COMPATIBLE True) endif()

wgengland gravatar image wgengland  ( 2020-03-25 11:10:58 -0500 )edit

That cmake shows nothing- you set a variable to 4.2.0 and then just check that its 4.2.0. That equivalent to

String version = 4.2.0 If version == 4.2.0 (good)

stevemacenski gravatar image stevemacenski  ( 2020-03-25 12:49:21 -0500 )edit

this is the binary that installed so I do have this version

wgengland gravatar image wgengland  ( 2020-03-30 09:04:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-24 13:19:37 -0500

Seen: 4,332 times

Last updated: Mar 24 '20