0
$\begingroup$

Rosanswers logo

I was following the Converting between ROS images and OpenCV images (Python) tutorial and i came across the following problem while running catkin_make. I am new to ros and i am still finding my way around it. I have installed opencv and have tried out the solutions suggested in other threads, but none of them seem to work. This is the error i get while executing catkin_make.

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

    opencv2Config.cmake
    opencv2-config.cmake

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

my CMakeLists file has the following content

cmake_minimum_required(VERSION 2.8.3)
project(opencv_test)
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  opencv2
  rospy
  sensor_msgs
  std_msgs
)
find_package(OpenCV)
include_directories(
  ${catkin_INCLUDE_DIRS}
)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(opencv_test ${OpenCV_LIBRARIES})

Originally posted by spkulgod on ROS Answers with karma: 23 on 2016-05-27

Post score: 2


Original comments

Comment by ROSkinect on 2016-05-27:
Could you share the CMakeLists?

Comment by gvdhoorn on 2016-05-27:
Please add a link to any tutorials you are following and / or pages you are referring to. It's hard to figure out what you are doing otherwise.

Comment by spkulgod on 2016-05-27:
This is the link for the tutorial http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython

Comment by gvdhoorn on 2016-05-28:
That page only tells you to update your manifest, which is not CMakeLists.txt, but package.xml.

Comment by spkulgod on 2016-05-28:
yeah but the vision_opencv page asks me to edit the CMakeLists.txt the link for the isvision_opencv

Comment by gvdhoorn on 2016-05-28:
Again: that is for C++ only. Python programs/scripts/nodes are never linked against C++ libraries, nor do you setup an include path for them (or at least, not in the way that CMake snippet is doing).

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  opencv2
  ..

opencv2 is not a package, which is why CMake fails when it tries to find the config file.

Remove it from the catkin components. Just the find_package(OpenCV ..) should be enough.


Originally posted by gvdhoorn with karma: 86574 on 2016-05-27

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by spkulgod on 2016-05-27:
i tried doing that and i get a different error as shown below

CMake Error at opencv_test/CMakeLists.txt:121 (target_link_libraries):
  Cannot specify link libraries for target "opencv_test" which is not built
  by this project.


-- Configuring incomplete, errors occurred!

Comment by spkulgod on 2016-05-27:
This is probably because i have added opencv2 as a dependency while creating the package as told in the tutorial. Should i change it to opencv?

Comment by gvdhoorn on 2016-05-27:
Which makes sense, since you don't have any executable target named opencv_test anywhere in your CMakeLists.txt.

Comment by gvdhoorn on 2016-05-27:\

Converting between ROS images and OpenCV images (Python)

Is this in Python? If so, then none of this is needed. Python nodes are not compiled, and you have to do completely different things for them. See the catkin docs.

Comment by spkulgod on 2016-05-28:
thank you, i will try that out and get back.

Comment by spkulgod on 2016-05-30:
Thank you for the help, it seems to be working.

Comment by ToanJunifer on 2018-09-18:
spkulgod, How can you do that ? Teach me, pls

Comment by ToanJunifer on 2018-09-18:
I trying to change follow the guide but it's not working. And then i access on catkin docs,then i click on install Cmake file dont know what is was: `catkin_package(CFG_EXTRAS your_macros.cmake your_modules.cmake)

$\endgroup$

Your Answer

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