-
-
Save improve100/d6f6607df6e90ac1bc7c33d2149317d5 to your computer and use it in GitHub Desktop.
OpenCV 3 Installation 多版本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Added by me | |
sudo apt-get install freeglut3 freeglut3-dev libtbb-dev libqt4-dev | |
# install deps | |
sudo apt-get install build-essential cmake git pkg-config | |
sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev | |
sudo apt-get install libgtk2.0-dev | |
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev | |
sudo apt-get install libatlas-base-dev gfortran | |
# clone opencv source | |
mkdir softwares | |
cd softwares | |
git clone https://github.com/opencv/opencv.git | |
git clone https://github.com/opencv/opencv_contrib.git 安装时,这两个版本要对应 | |
cd opencv | |
mkdir build | |
cd build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.4/ -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF-D OPENCV_EXTRA_MODULES_PATH=/home/tong/3rdparty/opencv_contrib/modules -D PYTHON_EXECUTABLE=/home/tong/.pyenv/shims/python -D BUILD_EXAMPLES=ON .. | |
make -j$(nproc) | |
sudo make install | |
#sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' 无用 | |
sudo ldconfig | |
vim ~/.bashrc | |
export PKG_CONFIG_PATH=~/opencv-3.4.1/build/installed/lib/pkgconfig | |
export LD_LIBRARY_PATH=~/opencv-3.4.1/build/installed/lib | |
source ~/.bashrc | |
pkg-config --modversion opencv | |
多版本切换: | |
cmake_minimum_required(VERSION 2.8) | |
set(OpenCV_DIR "~/opencv-3.4.1/build") | |
project(test) | |
在python中使用opencv | |
pip install opencv-python #安装opencv | |
pip install opencv-contrib-python #安装opencv的contrib扩展包 | |
# Not needed but just do it, you will thank me later on. | |
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose | |
pip install Cython --install-option="--no-cython-compile" | |
sudo pip install -U scikit-image | |
find_package(OpenCV REQUIRED) | |
参考帖子:https://blog.csdn.net/ksws0292756/article/details/79511170 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment