OpenCV的全称是Open Source Computer Vision Library,是一个跨平台的计算机视觉库。OpenCV是由英特尔公司发起并参与开发,以BSD许可证授权发行,可以在商业和研究领域中免费使用。OpenCV可用于开发实时的图像处理、计算机视觉以及模式识别程序。该程序库也可以使用英特尔公司的IPP(收费库)进行加速处理。
1、依赖包安装
// CentOS 7 //安装编译包 # yum install -y gcc gcc-c++ openssl openssl-devel //安装图形特性功能 # yum install -y gtk* libdc1394-devel libv4l-devel ffmpeg-devel gstreamer-plugins-base-devel //安装图片功能 # yum install -y libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel libtiff-devel libwebp-devel
// Debian 11 # apt install gcc g++ libjpeg-dev libpng-dev libdc1394-22-dev libgstreamer-plugins-base1.0-dev libopenexr-dev libwebp-dev libgtk-3-0 libgtk-3-dev libgtk-3-bin ffmpeg libavcodec-dev libswscale-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev libavresample-dev
2、安装cmake-3.21.2
// CentOS 7 # wget https://cmake.org/files/v3.21/cmake-3.21.2.tar.gz # tar -zxvf cmake-3.21.2.tar.gz && cd cmake-3.21.2 # ./bootstrap # gmake && make install
// Debian 11 # apt install cmake
3、安装JDK 8
去oracle官网下载oracle jdk8(https://www.oracle.com/java/technologies/downloads/)
# mkdir /opt/usr && cd /opt/usr # tar -zxvf jdk-8u371-linux-x64.tar.gz //编辑环境变量配置(# vi /etc/profile),添加如下内容 # jdk environment JAVA_HOME=/opt/usr/jdk1.8.0_371 JRE_HOME=/opt/usr/jdk1.8.0_371/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
4、安装ant1.9.16
# cd /opt/usr # wget https://dlcdn.apache.org//ant/binaries/apache-ant-1.9.16-bin.tar.gz # tar -zxvf apache-ant-1.9.16-bin.tar.gz //编辑环境变量配置(# vi /etc/profile),添加如下内容 # ant env export ANT_HOME=/opt/usr/apache-ant-1.9.16 export PATH=$PATH:$ANT_HOME/bin
5、安装OpenCV4.5.3
# wget https://github.com/opencv/opencv/archive/refs/tags/4.5.3.tar.gz # wget https://github.com/opencv/opencv_3rdparty/blob/ippicv/master_20191018/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz //下载完成后,将ippicv_2020_lnx_intel64_20191018_general.tgz文件放于/tmp目录下 # tar -zxvf 4.5.3.tar.gz && cd opencv-4.5.3 # vi 3rdparty/ippicv/ippicv.cmake 修改42行https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/ 改为file:/tmp/ # mkdir build && cd build # cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/usr/opencv4.5.3 .. # make -j4 && make install
6、添加环境变量
# vi /etc/profile export OPENCV_HOME=/opt/usr/opencv export PATH=$PATH:$OPENCV_HOME/bin source /etc/profile
# vi /etc/ld.so.conf.d/libc.conf /opt/usr/opencv/lib ldconfig -v
转载请注明:LINUX服务器运维架构技术分享 » 编译安装OpenCV4.5.3