ubuntu16.04 安装opencv3.4.0/3.4.6
时间:2019-08-12 14:13 来源:linux.it.net.cn 作者:IT
方法一
进入http://opencv.org/releases.html下载opencv 3.4.0代码
解压zip文件,并进入opencv3.4.0目录
unzip opencv-3.4.0.zip
cd opencv-3.4.0
mkdir build
cd build
创建安装目录
sudo mkdir /usr/local/opencv3.4.0
cmake
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.4.0 … (其实是两点,但是显示出来却是三点)
5.编译和安装
make -j12
sudo make install
修改环境变量
vim ~/.bashrc
使用 zsh用户
vim ~/.zshrc
添加如下内容,并source ~/.bashrc使马上生效
export PKG_CONFIG_PATH="/usr/local/opencv3.4.0/lib/pkgconfig"
export LD_LIBRARY_PATH="LDLIBRARYPATH:/usr/local/opencv3.4.0/lib"zsh用户source /.zshrc使马上生效exportPKGCONFIGPATH= LD_LIBRARY_PATH:/usr/local/opencv3.4.0/lib" zsh用户source ~/.zshrc使马上生效export PKG_CONFIG_PATH=LD
L
IBRARY
P
ATH:/usr/local/opencv3.4.0/lib"zsh用户source /.zshrc使马上生效exportPKG
C
ONFIG
P
ATH=PKG_CONFIG_PATH:/usr/local/opencv3.4.1/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/opencv3.4.1/lib
查看opencv版本
pkg-config --modversion opencv
方法二
ubuntu上opencv源码安装 ubuntu版本16.04,opencv版本3.4.6,带CUDA源码安装 参考:https://docs.opencv.org/3.4.6/d7/d9f/tutorial_linux_install.html
1). 下载指定版本的opencv和opencv_contrib源代码
a) git clone https://github.com/opencv/opencv.git
cd opencv
b)git checkout
33b765d7979fd8a6038026aa44f6ff1a9c082b7b
git checkout -b 3.4.6
2)检查环境
查看gcc版本:which gcc,gcc -v 我的是5.4.0
查看CMake版本:cmake --version 我的是3.9.1
查看是否安装git:git --version 。。。。。。
3)安装环境
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
4)源码编译
mkdir build
cd build
cmake-gui …
配置CMAKE_BUILD_TYPE 值为RELEASE,
根据自己的情况,配置CMAKE_INSTALL_PREFIX和OPENCV_EXTRA_MODULES_PATH(opencv_contrib的路径),
勾选WITH_CUDA,
点击Generate生成配置文件。
在build目录下,执行:
make
sudo make install
参考:https://blog.csdn.net/jindunwan7388/article/details/80397700
5)环境变量配置
a)sudo gedit /etc/ld.so.conf.d/opencv.conf
将以下内容添加到最后:/usr/local/lib
sudo ldconfig
b)sudo gedit /etc/bash.bashrc
添加:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
执行 source /etc/bash.bashrc
c)重启
(责任编辑:IT)
方法一 进入http://opencv.org/releases.html下载opencv 3.4.0代码 解压zip文件,并进入opencv3.4.0目录 unzip opencv-3.4.0.zip cd opencv-3.4.0 mkdir build cd build 创建安装目录 sudo mkdir /usr/local/opencv3.4.0 cmake cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.4.0 … (其实是两点,但是显示出来却是三点) 5.编译和安装 make -j12 sudo make install 修改环境变量 vim ~/.bashrc 使用 zsh用户 vim ~/.zshrc 添加如下内容,并source ~/.bashrc使马上生效 export PKG_CONFIG_PATH="/usr/local/opencv3.4.0/lib/pkgconfig" export LD_LIBRARY_PATH="LDLIBRARYPATH:/usr/local/opencv3.4.0/lib"zsh用户source /.zshrc使马上生效exportPKGCONFIGPATH= LD_LIBRARY_PATH:/usr/local/opencv3.4.0/lib" zsh用户source ~/.zshrc使马上生效export PKG_CONFIG_PATH=LD L IBRARY P ATH:/usr/local/opencv3.4.0/lib"zsh用户source /.zshrc使马上生效exportPKG C ONFIG P ATH=PKG_CONFIG_PATH:/usr/local/opencv3.4.1/lib/pkgconfig export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/opencv3.4.1/lib 查看opencv版本 pkg-config --modversion opencv 方法二 ubuntu上opencv源码安装 ubuntu版本16.04,opencv版本3.4.6,带CUDA源码安装 参考:https://docs.opencv.org/3.4.6/d7/d9f/tutorial_linux_install.html 1). 下载指定版本的opencv和opencv_contrib源代码 a) git clone https://github.com/opencv/opencv.git cd opencv b)git checkout 33b765d7979fd8a6038026aa44f6ff1a9c082b7b git checkout -b 3.4.6 2)检查环境 查看gcc版本:which gcc,gcc -v 我的是5.4.0 查看CMake版本:cmake --version 我的是3.9.1 查看是否安装git:git --version 。。。。。。 3)安装环境 sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev 4)源码编译 mkdir build cd build cmake-gui … 配置CMAKE_BUILD_TYPE 值为RELEASE, 根据自己的情况,配置CMAKE_INSTALL_PREFIX和OPENCV_EXTRA_MODULES_PATH(opencv_contrib的路径), 勾选WITH_CUDA, 点击Generate生成配置文件。 在build目录下,执行: make sudo make install 参考:https://blog.csdn.net/jindunwan7388/article/details/80397700 5)环境变量配置 a)sudo gedit /etc/ld.so.conf.d/opencv.conf 将以下内容添加到最后:/usr/local/lib sudo ldconfig b)sudo gedit /etc/bash.bashrc 添加: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH 执行 source /etc/bash.bashrc c)重启 (责任编辑:IT) |