Home > database >  Conflict between OpenCV 4 and cv_bridge in ROS Node
Conflict between OpenCV 4 and cv_bridge in ROS Node

Time:12-03

I'm starting a project with OpenCV with ROS and i need to use xfeatures2d that is in opencv_contrib. I follow this instructions and modify my CMake File in this way:

cmake_minimum_required(VERSION 3.0.2)
project(visual_odometry)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  sensor_msgs
  nav_msgs
  geometry_msgs
  std_msgs
)

find_package(OpenCV 4 REQUIRED) 

catkin_package()

include_directories(
# include  
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

add_executable(show_image src/show_image.cpp)
target_link_libraries(show_image 
${catkin_LIBRARIES}
${OpenCV_LIBRARIES})

add_executable(show_video src/show_video.cpp)
target_link_libraries(show_video 
${catkin_LIBRARIES}
${OpenCV_LIBRARIES})

add_executable(visual_Odometry src/visual_Odometry.cpp)
target_link_libraries(visual_Odometry 
${catkin_LIBRARIES}
${OpenCV_LIBRARIES})

After catkin_make :

/usr/bin/ld: warning: libopencv_imgproc.so.4.5, needed by /usr/local/lib/libopencv_xfeatures2d.so.4.5.3, may conflict with libopencv_imgproc.so.3.2

During run time, some functions of imgproc like CLAHE algorithm doesn't work and my node stop to work.

When i build with catkin_make, cv_bridge find opencv3.2 default in ros, but my node find opencv4 thanks to CMake file. So, can I fix this? It is possible build in opencv3.2 a opencv_contrib? It is possibile to change the version of opencv in cv_bridge?

CodePudding user response:

I found a solution in Github:

In catkin_ws/src:

git clone https://github.com/fizyr-forks/vision_opencv/tree/opencv4
cd vision_opencv
git checkout opencv4
  • Related