Monday, December 17, 2018

Mixed installation and usage of opencv 2&3 (windows & linux)

System: Windows

Architecture: x64
Compiler: Visual studio
https://www.learnopencv.com/install-opencv3-on-windows/

Linux

To keep both opencv2 and opencv3
1. Uninstall opencv2 and opencv3, remove or lib and include files in /usr/ or /usr/local/
2. Install in local directory

The default install folder of OpenCV is /usr/local/. You can install OpenCV 3.1 to a separate location, say /home/your_username/opencv_3.1 with CMake option
cmake -D CMAKE_INSTALL_PREFIX=/home/your_username/opencv_3.1
To build your project with OpenCV 3.1 using CMake, add
set(OpenCV_DIR /home/your_username/opencv_3.1/share/OpenCV)
to your CMakeLists.txt, after project(projName). You can also link the corresponding libraries/headers manually or with IDE.

Manuall settings for OpenCV directory

When you manually set opencv directory, if you have problems in cmake


CMake Warning at C:/opencv-2.4.9/build/install/OpenCVConfig.cmake:165 (message):
  Found OpenCV Windows Pack but it has not binaries compatible with your
  configuration.

  You should manually point CMake variable OpenCV_DIR to your build of OpenCV
  library.
Call Stack (most recent call first):
  CMakeLists.txt:79 (find_package)


CMake Error at CMakeLists.txt:79 (find_package):
  Found package configuration file:

    C:/opencv-2.4.9/build/install/OpenCVConfig.cmake

  but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
  NOT FOUND.

There is a problem in opencv 2.4.8 in build/install/OpenCVConfig.cmake, so you should set the OpenCV_DIR as the build directory, and also set the OPCV_FOUND to true.
In the cmake file, add the following lines

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SET("OpenCV_DIR" "C:\\opencv-2.4.9\\build\\")
find_package(OpenCV REQUIRED)
set(OpenCV_FOUND TRUE)
if (NOT OpenCV_FOUND)
    message(FATAL_ERROR "OpenCV library not found")
else()
 include_directories(${OpenCV_INCLUDE_DIRS})
 include_directories(${OpenCV2_INCLUDE_DIRS})
 link_directories(${OpenCV_LIB_DIR})
endif()


No comments:

Post a Comment