Cannot build OpenCV

asked 2017-11-29 01:50:34 -0500

rozoalex gravatar image

updated 2022-01-22 16:16:37 -0500

Evgeny gravatar image

HI, I am following this http://wiki.ros.org/image_transport/T... but I got this

CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (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. Call Stack (most recent call first): depth_vision/CMakeLists.txt:10 (find_package)

-- Could not find the required component 'OpenCV'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found. CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (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. Call Stack (most recent call first): depth_vision/CMakeLists.txt:10 (find_package)

-- Configuring incomplete, errors occurred!

And this is my cmakelist

cmake_minimum_required(VERSION 2.8.3)
project(depth_vision)
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  std_msgs
  OpenCV REQUIRED
)
catkin_package(
 CATKIN_DEPENDS 
    cv_bridge 
image_transport 
roscpp rospy 
std_msgs
)
include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)
add_executable(depth_image_publisher_node src/depth_image_publisher.cpp)
add_dependencies(depth_image_publisher_node depth_image_publisher_generate_messages_cpp) target_linktarget_link_libraries(
   depth_image_publisher_node
   ${catkin_LIBRARIES}
   ${OpenCV_LIBRARIES}
 )

This is my package.xml

 <buildtool_depend>catkin</buildtool_depend>
  <build_depend>cv_bridge</build_depend>
  <build_depend>image_transport</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>OpenCV</build_depend>
  <build_export_depend>cv_bridge</build_export_depend>
  <build_export_depend>image_transport</build_export_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <build_export_depend>OpenCV</build_export_depend>
  <exec_depend>cv_bridge</exec_depend>
  <exec_depend>image_transport</exec_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>OpenCV</exec_depend>

And this is my only code fille depth_image_publisher.cpp

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <cv_bridge/cv_bridge.h>
#include <sstream>
int main(int argc, char** argv){
    ros::init(argc,argv,"depth_image_publisher");
    ros::NodeHandle nh;
    image_transport::ImageTransport it(nh);
    image_transport::Publisher pub = it.advertise("camera/image",1);
    cv::Mat image = cv::imread(argv[1],CV_LOAD_IMAGE_COLOR);
    cv::waitKey(30);
    sensor_msgs::ImagePtr msg = cv_bridge::CvImage(std_msgs::Header(),"bgr8",image).toImageMsg();
    ros::Rate loop_rate(5);
    while(nh.ok()){
        pub.publish(msg);
        ros::spinOnce();
        loop_rate.sleep();
    }
}

I really dont know why... Thanks!

edit retag flag offensive close merge delete