环境
centos6.5
opencv3.3.0
python3.4.9
下载
opencv可从GitHub下载https://github.com/opencv/opencv/tree/3.4.3可自行选择版本
python可从官网上下载https://www.python.org/downloads/source/
安装python
编译安装需要依赖gcc
yum install gcc -y
yum install openssl-devel -y
linux论坛给的是yum install openssl-devel zlib-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel -y
tar -zxvf Python-3.4.9.tgz
cd Python-3.4.9
./configure --prefix=/opt/python3
make
make install
这时默认的还是python2
mv /usr/bin/python /usr/bin/python_old2
创建python新链接
ln -s /opt/python3/bin/python3 /usr/bin/python
配置成功
但是这样直接该可能会对其他组件产生影响,比如在用yum的时候就会出File "/usr/bin/yum", line 30
这时需要修改/usr/bin/yum
安装opencv
先在python3中执行bin/pip3 install numpy opencv-python(目的在opencv编译后生成python库)
安装依赖包
yum install cmake gcc-c++ git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y
yum install ant -y(如果安装目录下需要java,则需要安装ant依赖)
安装ffmpeg
yum -y install epel-release
rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm(centos6)
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm(centos7)安装os进行安装
yum install ffmpeg ffmpeg-devel -y
unzip opencv-3.3.0.zip(3.3.0版本比较稳定)
cd opencv-3.3.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/opt/opencv ..
make
make isntall