(1) 源
cat /etc/centos-release
sudo yum -y update
yum list available opencv*
(2)工具
sudo yum groupinstall ‘Development Tools’
sudo yum install cmake git pkgconfig
(3)一些依赖
sudo yum install libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel libtiff-devel libwebp-devel
sudo yum install libdc1394-devel libv4l-devel gstreamer-plugins-base-devel
sudo yum install gtk2-devel
(4)
sudo yum install tbb-devel eigen3-devel
(5)python pip
$ curl “https://bootstrap.pypa.io/get-pip.py” -o “get-pip.py”
$ sudo python get-pip.py
(6)python分割环境
~/.bashrc by adding these two lines to the file.
$ source /usr/bin/virtualenvwrapper.sh
(7) 虚拟环境
Now is the time to create a virtual environment,let’s call it cv
$ mkvirtualenv cv
You will notice a (cv) indicator at your command line. It means that we are in the virtual environment where we will be installing OpenCV. You can exit this environment by typing
$ deactivate
if you are not in the cv virtual environment,just type in
$ workon cv
(8)python环境
$ python –version
and you should see Python 2.7 version.
Install Python 2.7 development tools
$ sudo yum install python-devel
Install NumPy since OpenCV is using its arrays (and it is a very powerful package as well)
$ sudo pip install numpy
(9)install opencv
@H_110_404@
$ cd build
cmake-DCMAKE_BUILD_TYPE=RELEASE\
-DCMAKE_INSTALL_PREFIX=/usr/local\
-DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules\
-DINSTALL_C_EXAMPLES=OFF\
-DINSTALL_PYTHON_EXAMPLES=ON\
-DBUILD_EXAMPLES=ON\
-DBUILD_OPENCV_PYTHON2=ON.. sudo make
Check the following folder and see if OpenCV is installed
/usr/local/lib/python2.7/site-packages
(10) 虚拟环境安装
Now is the time to create a symbolic link to OpenCV library into the site-packages directory of the cv virtual environment:
Your installation is successfuly completed. You can confirm it by going into the virtual environment and importing OpenCV library.
原文链接:https://www.f2er.com/centos/376433.htmlimport cv2
cv2.version 3.1.0’