Opencv in ROS: fatal error: opencv3/opencv.hpp: No such file or directory compilation terminated.
EDITED:
Hello,
I just started using opencv with ROS and I am trying to to write a program using the default opencv3, which comes with ROS Kinetic. I have the following inclusions in my .cpp file:
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv3/opencv.hpp>
#include <opencv3/imgproc/imgproc.hpp>
#include <opencv3/highgui/highgui.hpp>
the following package.xml:
<buildtool_depend>catkin</buildtool_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>image_transport</build_depend>
<build_depend>image_geometry</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>opencv3</build_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>cv_bridge</run_depend>
<run_depend>image_transport</run_depend>
<run_depend>image_geometry</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>opencv3</run_depend>
and the following CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8.3)
project(kinect_vision)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
sensor_msgs
std_msgs
cv_bridge
image_transport
image_geometry
roscpp
)
find_package(OpenCV REQUIRED) ##I also tried it without REQUIRED
catkin_package(
INCLUDE_DIRS include
# LIBRARIES kinect_vision
CATKIN_DEPENDS cv_bridge image_transport image_geometry roscpp
DEPENDS OpenCV
)
include_directories(
${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS}
)
add_executable(kinect_vision_node src/kinect_vision_node.cpp)
target_link_libraries(kinect_vision_node
${OpenCV_LIBRARIES} ${catkin_LIBRARIES}
)
I get the following errors while trying to catkin_make my workspace:
/home/legged/vision_ws/src/kinect_vision/src/kinect_vision_node.cpp:5:30: fatal error: opencv3/opencv.hpp: No such file or directory
compilation terminated.
kinect_vision/CMakeFiles/kinect_vision_node.dir/build.make:62: recipe for target 'kinect_vision/CMakeFiles/kinect_vision_node.dir/src/kinect_vision_node.cpp.o' failed
make[2]: *** [kinect_vision/CMakeFiles/kinect_vision_node.dir/src/kinect_vision_node.cpp.o] Error 1
CMakeFiles/Makefile2:385: recipe for target 'kinect_vision/CMakeFiles/kinect_vision_node.dir/all' failed
make[1]: *** [kinect_vision/CMakeFiles/kinect_vision_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
Any ideas how can I fix this?
Thanks for your answers and for your time in advance,
Chris