ROSのOpenCVではまる

ROS Indigoでcatkin_makeしたときに以下のエラーではまったのでメモ

CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:75 (find_package):
Could not find a package configuration file provided by “OpenCV” with any
of the following names:

OpenCVConfig.cmake
opencv-config.cmake

Add the installation prefix of “OpenCV” to CMAKE_PREFIX_PATH or set
“OpenCV_DIR” to a directory containing one of the above files. If “OpenCV”
provides a separate development package or SDK, be sure it has been
installed.

解決した手順

1.OpenCVをインストール

  • $ sudo apt-get install ros-indigo-vision-opencv libopencv-dev python-opencv
  • $ rospack profile

2.CMakeLists.txtに以下を追加

  • find_package(OpenCV REQUIRED)
  • include_directories(/usr/local/include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} )
  • target_link_libraries(dfollow ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})

3. package.xmlに以下を追加

  • <build_depend>opencv2</build_depend>
  • <run_depend>opencv2</run_depend>

以上

コメント

タイトルとURLをコピーしました