0
$\begingroup$

Rosanswers logo

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


Originally posted by MrOCW on ROS Answers with karma: 58 on 2022-05-02

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by MrOCW with karma: 58 on 2022-05-02

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Sriniketh on 2023-02-28:
Hi, I am facing a similar issue. I have ROS noetic installed on my PC. During ROS installation, OpenCV 4.2 was installed without CUDA support. I am using a custom package which needs OpenCV with CUDA support. So I installed OpenCV 4.7.0 form source. In my CMakeLists I have given my path to the 4.7.0 build folder. During the the catkin make 4.7.0 version is found and catkin_make was successful with few warnings. When i try to run my roslaunch, I gets terminated as you mentioned showing No CUDA support. Can you please guide me how did you resolved in your case.

Thank you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.