1.注意事项:安装目录!
cmake-DCMAKE_BUILD_TYPE=Release-DCMAKE_INSTALL_PREFIX=/usr/local/opencv3.1.0..1
CMAKE_INSTALL_PREFIX之后的路径就是opencv的安装目录了。之前的opencv2.4.13安装到了根目录,即/usr/local/里,所以之后的opencv3.1.0安装到了/usr/local/opencv3.1.0/中这里,两个版本opencv目录一定要分开,不能安装到同一个路径下,否则会出现问题!
2.切换方式
切换方式其实比较简单,把环境变量的路径改一下就可以了。
a、
sudogedit/etc/ld.so.conf.d/opencv.conf1
把opencv的lib路径添加进去:
opencv3.1.0:
/usr/local/opencv-3.1.0/lib1
opencv2.4.13:
/usr/local/lib1
b、
sudoldconfig1
c、
sudogedit/etc/profile1
在最后加入PATH路径:
opencv3.1.0:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv-3.1.0/lib/pkgconfig
exportPKG_CONFIG_PATH12
opencv2.4.13:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
exportPKG_CONFIG_PATH12
d、
sudogedit/etc/bash.bashrc1
在最后添加PATH路径:
opencv3.1.0:
exportPKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv-3.1.0/lib/pkgconfig1
opencv2.4.13:
exportPKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig1
3.查看opencv版本:
pkg-config--modversionopencv
pkg-config--cflagsopencv
pkg-config--libsopencv123
实际使用中发现还是在寻找opencv2.4.13.
如果编译使用的是cmake,打开CMakeLists.txt,添加:
set(OPENCV_DIR“/home/ubuntu/opencv-3.1.0/build”)
如果上述方法还没有作用,那么就只好卸载不需要的opencv版本了:
cdopencv-2.4.13/release
sudomakeuninstall
cd..
sudorm-rrelease
sudorm-r/usr/local/include/opencv2/usr/local/include/opencv/usr/include/opencv/usr/include/opencv2/usr/local/share/opencv/usr/local/sl