Centos install opencv - 百年刘傲天

in 默认分类 with 0 comment

Centos安装opencv

首先是为opencv安装依赖项

yum groupinstall "Development Tools" -y
yum install cmake gcc gtk2-devel numpy pkconfig -y

加了-y是直接同意安装的意思
接下来下载opencv并编译安装

mkdir opencv_install;cd opencv_install
wget https://github.com/opencv/opencv/archive/4.0.0.zip
unzip 4.0.0.zip
cd opencv-4.0.0
mkdir build
cmake -D CMAKE_BUILD_TYPE=DEBUG -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
make install

我在这里遇到一个麻烦

那就是cmake版本过低,于是开始手动编译一下cmake

wget https://cmake.org/files/v3.6/cmake-3.6.2.tar.gz    
tar xvf cmake-3.6.2.tar.gz && cd cmake-3.6.2/
./bootstrap
gmake
gmake install

测试

/usr/local/bin/cmake --version

看到版本号就OK,成功,接下来就是删除掉原来的cmake替换这个过去

删除

yum remove cmake -y
lb-s /usr/local/bin/cmake /usr/bin/
cmake --version

cmake 更新成功

配置路径问题

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/
echo '/usr/local/lib/' >> /etc/ld.so.conf.d/opencv.conf
ldconfig
Responses