ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

CMake detects intended OpenCV+CUDA, but runtime does not use intended OpenCV version

asked 2022-05-02 05:00:28 -0600

MrOCW gravatar image

updated 2022-05-02 05:09:02 -0600

CMakeLists.txt contains

find_package( OpenCV 4.5.5 REQUIRED
  PATHS /usr/local
  NO_DEFAULT_PATH)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  geometry_msgs
  image_transport
  message_filters
  nav_msgs
  roscpp
  std_msgs
  tf
)

if(USE_CUDA)
    find_package(CUDA)
    include_directories("${CUDA_INCLUDE_DIRS}")
    add_definitions(-DUSE_CUDA)
endif(USE_CUDA)

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

add_executable( xxxxx src/xxxxx.cpp )
target_link_libraries( xxxxx ${OpenCV_LIBS} ${catkin_LIBRARIES .........}

Output of catkin_make -DUSE_CUDA=ON

-- Found CUDA: /usr/local/cuda (found suitable exact version "11.6") 
-- Found OpenCV: /usr/local (found suitable version "4.5.5", minimum required is "4.5.5") 
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Found CUDA: /usr/local/cuda (found version "11.6")

and everything builds and compiles nicely

However, when i run my node, it shows OpenCV(4.2.0) without CUDA:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.2.0) ../modules/core/include/opencv2/core/private.cuda.hpp:109: error: (-216:No CUDA support) The library is compiled without CUDA support in function 'throw_no_cuda'

I've built OpenCV 4.5.5 with CUDA. Non ROS applications are able to use it correctly

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-05-02 05:31:44 -0600

MrOCW gravatar image

Figured out the solution. Issue seems to be cv_bridge using OpenCV 4.2. I compiled vision_opencv with my intended opencv version and it works now.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-05-02 05:00:28 -0600

Seen: 275 times

Last updated: May 02 '22