0

I'm trying to learn OpenCV but for some reason I can't use the library, I'm using CMake but i don't know how to use and the code is

cmake_minimum_required(VERSION 3.0.0)
project(opencvtest VERSION 0.1.0)

include(CTest)
enable_testing()

find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )

add_executable(opencvtest main.cpp)

target_link_libraries( opencvtest ${OpenCV_LIBS} )

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

and always give the error

[cmake] CMake Error at CMakeLists.txt:7 (find_package):
[cmake]   By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
[cmake]   asked CMake to find a package configuration file provided by "OpenCV", but
[cmake]   CMake did not find one.

I'm used the video of someone in the youtube and their code work but mine doesn't and I did the same as their code

mentioned video

CADSE
  • 1
  • 1
  • where and how have you installed opencv? – Alan Birtles Dec 12 '21 at 08:32
  • from official website – CADSE Dec 12 '21 at 08:46
  • Find out where file `OpenCVConfig.cmake` exists inside your OpenCV installation, and specify directory with that file in variable `OpenCV_DIR`. Answers to the [duplicate question](https://stackoverflow.com/questions/8711109/could-not-find-module-findopencv-cmake-error-in-configuration-process) provide different ways of setting the variable. – Tsyvarev Dec 12 '21 at 09:39
  • ok, so you downloaded it from the website, how did you then install it and where did you install it to? – Alan Birtles Dec 12 '21 at 11:23
  • ah I already solved this error I put ```OpenCV_DIR``` in the folder that has ```OpenCVConfig.cmake``` I thought it wasn't necessary to say nothing because the site says that my question is closed – CADSE Dec 12 '21 at 11:33

0 Answers0