当前位置:   article > 正文

Ubuntu安装OpenCV时Could not find a package configuration file provided by “OpenCV“

could not find a package configuration file provided by "opencv" with any of

安装opencv过程省略,具体可查找其他博主的教程。
在catkin_make时,出现以下错误:

CMake Error at /opt/ros/melodic/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):
  probot_vision_pick/probot_ocr/CMakeLists.txt:12 (find_package)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

查看error

网上很多都说改CMakeList.txt,然后添加set(…)的路径。
一开始改了我的工作空间的src下的CMakeList.txt,发现不对,其实应该是打开error中显示的路径的CMakeLists.txt

Call Stack (most recent call first):
  probot_vision_pick/probot_ocr/CMakeLists.txt:12 (find_package)
  • 1
  • 2

如图所示:

set(OpenCV_DIR /opt/ros/kinetic/share/OpenCV-3.3.1-dev)
find_package(catkin REQUIRED COMPONENTS
.........省略
  • 1
  • 2
  • 3

修改成

# set(OpenCV_DIR /opt/ros/kinetic/share/OpenCV-3.3.1-dev)
set(OpenCV_DIR /usr/share/OpenCV)
find_package(catkin REQUIRED COMPONENTS
......省略
  • 1
  • 2
  • 3
  • 4

!!!注意,/usr/share/OpenCV,为OpenCVConfig.cmake的路径,可以在终端输入

locate OpenCVConfig.cmake
  • 1

得到其所在目录。
保存,重新catkin_make即可。

PS:注意要多看终端的报错,有时第一个error即是问题关键,后边的只是连锁反应而已。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/292918
推荐阅读
相关标签
  

闽ICP备14008679号