Could not find module FindOpenCV.cmake ( Error in configuration process)

前端 未结 12 2182
既然无缘
既然无缘 2020-11-29 02:04

I wrote a CMakeLists.txt for a project in C++, which uses OpenCV libraries. When I try to create the project using cmake, I ge

相关标签:
12条回答
  • 2020-11-29 02:17
    1. apt-get install libopencv-dev
    2. export OpenCV_DIR=/usr/share/OpenCV
    3. the header of cpp file should contain: #include #include "opencv2/highgui/highgui.hpp"

    #include #include

    not original cv.h

    0 讨论(0)
  • 2020-11-29 02:19

    I had the same error, I use windows. I add "C:\opencv\build" (opencv folder) to path at the control pannel. So, That's Ok!!

    0 讨论(0)
  • 2020-11-29 02:21

    The error you're seeing is that CMake cannot find a FindOpenCV.cmake file, because cmake doesn't include one out of the box. Therefore you need to find one and put it where cmake can find it:

    You can find a good start here. If you're feeling adventurous you can also write your own.

    Then add it somewhere in your project and adjust CMAKE_MODULE_PATH so that cmake can find it.

    e.g., if you have

    CMakeLists.txt
    cmake-modules/FindOpenCV.cmake
    

    Then you should do a

    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
    

    In your CMakeLists.txt file before you do a find_package(OpenCV)

    0 讨论(0)
  • 2020-11-29 02:24

    if you are on windows, you can add opencv path to OpenCV_DIR yourself. (OpenCV_DIR is in the red region)

    the path is like "D:/opencv244/build".

    you can find file "OpenCVConfig.cmake" under the path.

    0 讨论(0)
  • 2020-11-29 02:25

    On my Fedora machine, when I typed "make" I got an error saying it could not find "cv.h". I fixed this by modifying my "OpenCVConfig.cmake" file.

    Before:

    SET(OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include/opencv;${OpenCV_INSTALL_PATH}/include")

    SET(OpenCV_LIB_DIR "${OpenCV_INSTALL_PATH}/lib64")

    After:

    SET(OpenCV_INCLUDE_DIRS "/usr/include/opencv;/usr/include/opencv2")

    SET(OpenCV_LIB_DIR "/usr/lib64")

    0 讨论(0)
  • 2020-11-29 02:29

    I am using Windows and get the same error message. I find another problem which is relevant. I defined OpenCV_DIR in my path at the end of the line. However when I typed "path" in the command line, my OpenCV_DIR was not shown. I found because Windows probably has a limit on how long the path can be, it cut my OpenCV_DIR to be only part of what I defined. So I removed some other part of the path, now it works.

    0 讨论(0)
提交回复
热议问题