1. 下载OpenCV
- OpenCV – 3.4.12下载
解压后进入目录并创建build目录
unzip opencv-3.4.12.zip
cd opencv-3.4.12
mkdir build
2. 安装预编译环境
sudo yum -y install epel-release
sudo yum -y install git gcc gcc-c++ cmake3
sudo yum -y install gtk2-devel
sudo yum install -y libpng-devel
sudo yum install -y jasper-devel
sudo yum install -y openexr-devel
sudo yum install -y libwebp-devel
sudo yum -y install libjpeg-turbo-devel
sudo yum install -y freeglut-devel mesa-libGL mesa-libGL-devel
sudo yum -y install libtiff-devel
sudo yum -y install libdc1394-devel
sudo yum -y install tbb-devel eigen3-devel
sudo yum -y install boost boost-thread boost-devel
sudo yum -y install libv4l-devel
sudo yum -y install gstreamer-plugins-base-devel
3. 编译安装OpenCV
cd build
cmake3 -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j$(nproc) // 有几个cpu就写数字几 make -j4
make install
一般来说在10~20分钟左右就可以编译完成,完成后输入opencv_version
得到版本信息
4. 库文件和头文件目录位置
根据安装时的命令
- 头文件目录位于:
- 库文件目录位于
5. 后话
因为我用不到图形化和python环境,所以预编译时关于QT和pyhton的环境都省去了,有兴趣的同学可以参考下面的链接,自行摸索。
省略掉的预编译安装:
sudo yum -y install qt5-qtbase-devel
sudo yum install -y python34 python34-devel python34-pip
sudo yum install -y python python-devel python-pip
sudo yum -y install python-devel numpy python34-numpy
参考:
- CentOS 里安装 OpenCV
- Install OpenCV 4 on CentOS 7 (C++ and Python)