配置好epel源
yum -y install epel-release
yum install -y gcc gcc-c++
yum install -y cmake
yum install -y python-devel numpy
CentOS 6&7安装ffmpeg
安装opencv
cd /usr/local
wget https://github.com/opencv/opencv/archive/3.4.3.zip
unzip 3.4.3.zip
cd opencv-3.4.3
mkdir release
cd release
cmake -D WITH_TBB=ON -D WITH_EIGEN=ON ..
cmake -D BUILD_DOCS=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF ..
cmake -D WITH_OPENCL=OFF -D WITH_CUDA=OFF -D BUILD_opencv_gpu=OFF -D BUILD_opencv_gpuarithm=OFF -D BUILD_opencv_gpubgsegm=OFF -D BUILD_opencv_gpucodec=OFF -D BUILD_opencv_gpufeatures2d=OFF -D BUILD_opencv_gpufilters=OFF -D BUILD_opencv_gpuimgproc=OFF -D BUILD_opencv_gpulegacy=OFF -D BUILD_opencv_gpuoptflow=OFF -D BUILD_opencv_gpustereo=OFF -D BUILD_opencv_gpuwarping=OFF ..
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
编译前设置pkgconfig路径:
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/
cd /usr/local/opencv-3.4.3/release
make
make install
安装好后需要加动态库配置:
/bin/bash -c 'echo "/usr/local/lib64" > /etc/ld.so.conf.d/opencv.conf'
ldconfig
查看是否安装成功 (没有出错说明安装成功)
pkg-config —cflags opencv
pkg-config —libs opencv
|