ubuntu14.04, you have installed OpenCV2 (the default installation path is/usr/local) and now you need to install OpenCV3.2, but you do not want to remove Opencv2
1. First, after downloading the good opencv3.2 (download: https://github.com/opencv/opencv/archive/3.2.0.zip), unzip the source code
2. Modify the CMakeLists.txt file
Change the default installation path:/usr/local to the path you want to install
set(CMAKE_INSTALL_PREFIX "/home/alan/slambook/opencv3" CACHE PATH "Installation Directory")
3. Compiling
cmake ..makemake install
在指定安装的路径下找到对应的头文件和库
4.
如何在工程中加入opencv3.2的库和头文件。
这里需要改变一下,否则很容易链接到位于/usr/local下的opencv2。在工程文件中的CMakeLists.txt加上:
Set (Opencv_dir "/home/ubuntu/src/opencv-3.1.0/build")
< Span class= "hljs-built_in" > was generated when the OPENCV2 was installed
opencv_dir =/USR/LOCAL/SHARE/OPENCV, so it is necessary to use set to change the value of this variable, the new path is the same as the file Opencvconfig.cmake path.
Cmake_minimum_required (VERSION 2.8) Project (loop_closure) Set (Cmake_build_type "Release") Set (cmake_cxx_flags "-std= C++11-o3 ") # OpenCV Set (opencv_dir"/home/lzp/software/opencv-3.2.0/build ") find_package (OpenCV REQUIRED) Include_ Directories (${opencv_include_dirs}) message (STATUS " version: ${opencv_version}") # dbow3 # dbow3 is a simple lib so I assume you installed the it in default directory set (dbow3_include_dirs "/usr/local/include") Set (dbow3_libs "/usr/local/l Ib/libdbow3.a ") add_executable (feature_training feature_training.cpp) target_link_libraries (feature_training ${ Opencv_libs} ${dbow3_libs}) add_executable (Loop_closure loop_closure.cpp) target_link_libraries (loop_closure ${ Opencv_libs} ${dbow3_libs}) add_executable (Gen_vocab gen_vocab_large.cpp) target_link_libraries (Gen_vocab ${OpenCV_ LIBS} ${dbow3_libs})
Coexistence of Opencv2 and Opencv3 under UBUNTU14