0
$\begingroup$

Rosanswers logo

Hi ALl,

I am very new into ROS. I wanted to use GPU support from OpenCv inside ROS platform. But I faced an error where it said ROS opencv is built without CUDA support. The I tried to build myself OpenCv(after downloading from OpenCv website) with CUDA support into the /usr/local . I wanted to test it with a simple code. But EVen though the version I downloaded and built is built with CUDA. My project somehow connects to the CV from ROS-fuerte and gives me an error as below.

OpenCV Error: No GPU support (The library is compiled without CUDA support) in mallocPitch, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1632/modules/core/src/gpumat.cpp, line 749 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1632/modules/core/src/gpumat.cpp:749: error: (-216) The library is compiled without CUDA support in function mallocPitch

I have two questions. I am sure many of you will find it very simple problem. I am unable to understand how I can solve the below problems..

  1. How can I use my local copy of OpenCv which I built with CUDA support ?
  2. Is it possible to use it also in ROS ignoring the prebuilt openCv in ROS which is without CUDA support ?

regards, Subhasis


Originally posted by Subhasis on ROS Answers with karma: 31 on 2012-11-01

Post score: 5


Original comments

Comment by longzhixi123 on 2013-04-23:
can you use cuda with opencv in ROS? if you can ,would you share your Experience?my mail is [email protected] thanks a lot .

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Yes, you can use your custom-built OpenCV instead of those provided by ROS.

Add this line to your .bashrc(or anywhere similarly where you set ROS environments):

export CMAKE_PREFIX_PATH=/usr/local:$CMAKE_PREFIX_PATH

Make sure your CMAKE_PREFIX_PATH is like this(/usr/local is the path prefix where you installed OpenCV):

$ echo $CMAKE_PREFIX_PATH
/usr/local:/opt/ros/fuerte/share/catkin/cmake/Modules:/opt/ros/fuerte

Then add these lines to your CMakelists.txt:

find_package(OpenCV 2.4 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
...
target_link_libraries(YOUR_TARGET ${OpenCV_LIBS})

Start a new term and remove old build/* files, then make again. In this case CMake can find your installed OpenCV first.


Originally posted by K Chen with karma: 391 on 2012-11-01

This answer was ACCEPTED on the original site

Post score: 7


Original comments

Comment by Rookdroid on 2013-03-13:
Hi K Chen, I've followed your steps however I am still having some issues with my program still being compiled with OPENCV2.4.2. I trying to debug this with no success. I checked the pkg that CMAKE is grabbing which is OPENCV2.3.1 which is what I want but when I compile and run I get 2.4.2 errors.

Comment by K Chen on 2013-03-14:
Which version of OpenCV do you want? ROS Fuerte provides OpenCV 2.4.x and if you want to use other versions or your custom built libs, refer to the instruction above and change the version xx in find_package(OpenCV xx)

Comment by 746666288 on 2013-03-24:
Hi K Chen,I want to know what should be changed in your sugestions with ROS-electric? thanks

Comment by K Chen on 2013-03-31:
I am not sure if this works for ROS Electric, but the $CMAKE_PREFIX_PATH is available for all current CMake versions, so you can give it a try. And if you have a rosdep in your manifest.xml, don't forget to remove it, or it can be confusing if you depends on two OpenCV version.

Comment by 746666288 on 2013-03-31:
thanks .your comments are very useful.haha

Comment by naveenT1010 on 2017-05-27:
Hi, I am also trying to use GPU enabled OpenCV with ROS and I tried this method. I am able to compile the code but when starting the node with rosrun, it tries to get my kinetic opencv which is not GPU enabled and throws CUDA not enabled excetion. Any solutions for that?

$\endgroup$

Your Answer

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