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

How to manually build OpenCV to work with ROS?

asked 2013-03-06 04:37:38 -0500

AdrianPeng gravatar image

updated 2014-01-28 17:15:33 -0500

ngrennan gravatar image

Since ROS doesn't have binary package for ARM, I cannot use "apt-get install ros-groovy-opencv2" to download and install OpenCV libraries for ROS ("E: Unable to locate package" will appear). Can anyone give me some hints to manually download, install and wrap OpenCV libraries with ROS?

Thanks for any help in advance!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-06 04:55:01 -0500

stantol gravatar image

updated 2013-03-06 04:56:17 -0500

I haven't done anything similar with groovy, but I think it should work more-or-less the same, since it's all CMake based. When I wanted to install OpenCV with CUDA, I did the process below. Note: I am a novice at building with CMake, so there are probably better ways of doing this.

  1. Install OpenCV to a specific directory following the instructions on their website.

  2. Create a CMakeModule folder within your working program directory, find a version of FindOpenCV.cmake to copy into that folder, then specify the path to OpenCV by adding the line:

    set(OpenCV_DIR "/directory/to/opencv2")

  3. In your program's CMake file, add:


    find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) add_definitions(${OpenCV_DEFINITIONS}) MESSAGE(STATUS "OpenCV at: ${OpenCV_INCLUDE_DIRS}")

    more code

    target_link_libraries(executable_name ${OpenCV_LIBRARIES})

There might be some specifics that are incorrect, but I think the general idea should work.

edit flag offensive delete link more


Thanks for your reply! I will try it. By the way, which opencv version do you suggest for ARM?

AdrianPeng gravatar image AdrianPeng  ( 2013-03-06 05:24:02 -0500 )edit

I have no experience with ARM processors, so I can't offer any advice.

stantol gravatar image stantol  ( 2013-03-06 05:32:12 -0500 )edit

answered 2013-05-21 04:46:05 -0500

enddl22 gravatar image

Thank you for your short tutorial.

I am quite new to CMake and have questions.

  1. Which file do I need to set OpenCV_DIR, I guess it should be FindOpenCV.cmake.

  2. Where can I get FindOpenCV.cmake file? Is it right?

  3. set(OpenCV_DIR "/directory/to/opencv2"), where is /directory/to/opencv2? Is this the installation directory(default: /usr/local) or source root directory or build root directory?

It keeps saying

/usr/local/include/opencv/highgui.h:45:33: fatal error: opencv2/core/core_c.h: No such file or directory compilation terminated.

Thank you.

edit flag offensive delete link more


  1. Yes, the way that I did it, I set that variable in FindOpenCV.cmake.
  2. That FindOpenCV.cmake should probably work fine.
  3. /directory/to/opencv2 should be the directory of the OpenCV you want to use (e.g., one that you compiled with CUDA, a newer/older version, etc.).
stantol gravatar image stantol  ( 2013-05-21 09:45:41 -0500 )edit

Question Tools



Asked: 2013-03-06 04:37:38 -0500

Seen: 2,387 times

Last updated: May 21 '13