compile opencv in centos

前端之家收集整理的这篇文章主要介绍了compile opencv in centos前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

(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分割环境
sudopipinstallvirtualenvvirtualenvwrapper sudo rm -rf ~/.cache/pip

~/.bashrc by adding these two lines to the file.
exportWORKONHOME= HOME/.virtualenvs
$ 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
cd git clone https://github.com/Itseez/opencv.git
cdopencv git checkout 3.1.0

cd git clone https://github.com/Itseez/opencv_contrib.git
cdopencvcontrib git checkout 3.1.0

@H_110_404@ cd/opencv mkdir build
$ 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
sudomakeinst@H_743_502@all sudo ldconfig

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:

cd/.virtualenvs/cv/lib/python2.7/sitepackages/ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
Your installation is successfuly completed. You can confirm it by going into the virtual environment and importing OpenCV library.

workoncv python

import cv2
cv2.version 3.1.0’

原文链接:https://www.f2er.com/centos/376433.html

猜你在找的CentOS相关文章