9

I have downloaded the source code of the face-analysis SDK from http://face.ci2cv.net/. Now I am trying to get it running. I downloaded all the necessary software and followed the installation instructions. When I try to execute cmake [options] .. I get an error.

CMake Error at CMakeLists.txt:21(find_package):
Could not find a package configuration file provided by "OpenCV" with any of the following names:
OpenCVConfig.cmake
opencv-comfig.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. 

The CMakeLists.txt looks like this

# -*-cmake-*-
PROJECT(CSIRO-FaceAnalysis-SDK)

cmake_minimum_required(VERSION 2.8)

#set(CMAKE_VERBOSE_MAKEFILE true)

# Default values for options
if(NOT DEFINED OpenCV_PREFIX)
  set(OpenCV_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()


  set(OpenCV_PREFIX C:/Program Files/Development/opencv/build)
endif(
# Configurable options
OPTION(WITH_GUI "Build the GUI" OFF)

# Third party libraries
find_package(OpenCV REQUIRED core highgui imgproc objdetect
  PATHS ${OpenCV_PREFIX}/lib/cmake/
        ${OpenCV_PREFIX}/share/OpenCV/
  NO_DEFAULT_PATH) # For some reason CMake uses its defaults before the above paths.

Please help me, I have no idea what to do.

Thanks, B

berak
  • 39,159
  • 9
  • 91
  • 89
bxxxi
  • 153
  • 1
  • 1
  • 7

2 Answers2

14
  1. Check that OpenCV is installed on your system. Note the folder where it is installed. For example: C:\OpenCV
  2. Execute CMake with a command line similar to

cmake -DCMAKE_PREFIX_PATH="C:\OpenCV" ..

OR

find the folder containing OpenCVConfig.cmake (for example C:\OpenCV\build\x86\vc10\lib) and pass it to CMake via the variable OpenCV_DIR

cmake -DOpenCV_DIR="C:\OpenCV\build\x86\vc10\lib" ..

In both cases, I think the provider of the code you try to compile commited an error by putting NO_DEFAULT_PATH in the find_package(OpenCV ...). If nothing work, re-try after removing this flag.

Antwane
  • 20,760
  • 7
  • 51
  • 84
  • Thanks for your help. It worked. But I am already facing the next problem.In the documentation it says: When CMake has successfully configured the project, issue "make". From the context I get that I need this make command to complete the build. However, when I simply enter make in my cmd line it says that there is no such command. Can you please help me? Thanks, B – bxxxi Nov 25 '14 at 15:21
  • If you are on Windows it depends on your environment. Try `mingw-make` instead if you want to use GCC from MinGW. Try `nmake` if you use MSVC compiler. Anyway, I suggest you to read some basic documentation on CMake usage, and particularity of your platform (Windows I guess). Many questions on StackOverflow will also help you. Example: http://stackoverflow.com/questions/4219479/using-cmake-with-windows-7-visual-studio-2010-and-the-command-line – Antwane Nov 25 '14 at 15:49
  • Thanks again for your help. I already read some of the basic documentations on CMake. But I do not really get it. I am using Windows 8.1 and I have installed visual Studio so I have access to nmake.exe. Does this bring me any further? – bxxxi Nov 25 '14 at 18:16
  • 2
    So after running CMake, you should be able to run nmake to achieve compilation. What problem do you face? – Antwane Nov 25 '14 at 18:34
  • After the configuration with CMake is done. I try to run nmake but I get the message: the command nmake cannot be found. – bxxxi Nov 25 '14 at 19:06
  • 1
    I quote your words: `I have installed visual Studio so I have access to nmake.exe`. Do you have access to nmake or not? Please create a new question for this specific issue. It is too complex to be answered in comments of another answer – Antwane Nov 25 '14 at 19:35
2

I ran into this same problem a few days ago and this is the code I used to install it onto my system and make it in a way for CMakeLists.txt to understand how to locate those files. This process works for other packages as well.

cd ~/

git clone https://github.com/opencv/opencv.git

cd opencv

mkdir install

cd install

cmake ../

make

sudo make install

NOTE: It took a long time for opencv to make because of its complexity and size but I am sure there is a way to download and make only certain parts you need. I did not do that because I did not know how.

Dharman
  • 30,962
  • 25
  • 85
  • 135