2017-06-04 5 views
0

Ich habe installiert OpenCV-3.2 und ich kann das bin und lib Dateien sehenCmake sucht nach opencv Bibliothek

$ ls /share/apps/computer/opencv-3.2.0/built/bin/opencv_ 
opencv_annotation  opencv_createsamples opencv_traincascade  opencv_version  opencv_visualisation 
$ ls /share/apps/computer/opencv-3.2.0/built/lib/ 
libopencv_calib3d.so   libopencv_imgcodecs.so.3.2.0 libopencv_stitching.so.3.2 
libopencv_calib3d.so.3.2  libopencv_imgproc.so   libopencv_stitching.so.3.2.0 
libopencv_calib3d.so.3.2.0  libopencv_imgproc.so.3.2  libopencv_superres.so 
libopencv_core.so    libopencv_imgproc.so.3.2.0  libopencv_superres.so.3.2 
libopencv_core.so.3.2   libopencv_ml.so    libopencv_superres.so.3.2.0 
libopencv_core.so.3.2.0  libopencv_ml.so.3.2   libopencv_videoio.so 
libopencv_features2d.so  libopencv_ml.so.3.2.0   libopencv_videoio.so.3.2 
libopencv_features2d.so.3.2 libopencv_objdetect.so   libopencv_videoio.so.3.2.0 
libopencv_features2d.so.3.2.0 libopencv_objdetect.so.3.2  libopencv_video.so 
libopencv_flann.so    libopencv_objdetect.so.3.2.0 libopencv_video.so.3.2 
libopencv_flann.so.3.2   libopencv_photo.so    libopencv_video.so.3.2.0 
libopencv_flann.so.3.2.0  libopencv_photo.so.3.2   libopencv_videostab.so 
libopencv_highgui.so   libopencv_photo.so.3.2.0  libopencv_videostab.so.3.2 
libopencv_highgui.so.3.2  libopencv_shape.so    libopencv_videostab.so.3.2.0 
libopencv_highgui.so.3.2.0  libopencv_shape.so.3.2   pkgconfig/ 
libopencv_imgcodecs.so   libopencv_shape.so.3.2.0 
libopencv_imgcodecs.so.3.2  libopencv_stitching.so 

nun nach dem tutorial, schrieb ich ein einfaches Programm. Problem ist, dass cmake einige Fehler bekommt und scheint, dass es die Bibliothek nicht finden kann.

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

    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. 

Ich weiß nicht, wie CMAKE_PREFIX_PATH oder OpenCV_DIR einzustellen. Wie kann ich das beheben?

Der Inhalt CMakeLists.txt ist

cmake_minimum_required(VERSION 2.8) 
project(DisplayImage) 
find_package(OpenCV REQUIRED) 
add_executable(DisplayImage DisplayImage.cpp) 
target_link_libraries(DisplayImage ${OpenCV_LIBS}) 
+0

Wie haben Sie OpenCV auf Ihrem Computer installiert? und fügen Sie auch den Inhalt Ihrer 'CMakeLists.txt' – ZdaR

+0

Ich befolgte die Anweisungen. http://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html – mahmood

+0

Versuchen Sie mit diesem [link] (http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0 -und-python-2-7-on-ubuntu /) – ZdaR

Antwort

0

Es hängt davon ab, ob Sie OpenCVConfig.cmake Skript, das bei der Installation von OpenCV kommt (das heißt, unter Installationsverzeichnis /share/apps/computer/opencv-3.2.0/built/).

Wenn Ihre Installation von OpenCV von OpenCVConfig.cmake Skript fehlt, müssen Sie Ihr Projekt mit Skript versenden FindOpenCV.cmake (finden und kopieren Sie sie aus dem Netz, fast jeder von ihnen ist geeignet), und fügen Sie Verzeichnis mit diesem Skript zu CMAKE_MODULE_PATH Variable:

list(APPEND CMAKE_MODULE_PATH <directory-with-find-script>) 

Mögliche Wege CMake über Ihre Installation von OpenCV andeuten:

  1. Wenn Sie OpenCVConfig.cmake Skript haben, setzen OpenCV_DIR Variable Verzeichnis dieses Skript enthalten:

    cmake -DOpenCV_DIR=/share/apps/computer/opencv-3.2.0/built/<...> 
    
  2. Set CMAKE_PREFIX_PATH Variable Installation Präfix von OpenCV:

    cmake -DCMAKE_PREFIX_PATH=/share/apps/computer/opencv-3.2.0/built 
    

    Dies funktioniert sowohl mit OpenCVConfig.cmake und mit FindOpenCV.cmake Skripten. Siehe auch diese Frage: Hinting Find<name>.cmake Files with a custom directory.