啊,因为要打包so库,所以开始学习咯
下载压缩包
为了保证能用,不敢用最新版的,选择下载tag=3.4.15
https://github.com/opencv/opencv_contrib/releases/tag/3.4.15
https://github.com/opencv/opencv/releases/tag/3.4.15
下载zip文件,解压缩,opencv-3.4.15放到/home目录下,opencv_contrib-3.4.15放到opencv-3.4.15里边
依赖库
安装依赖
sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev
sudo apt-get install libavcodec-dev
sudo apt-get install libavformat-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libswscale-dev
sudo apt-get install libtiff5-dev
我还是一个一个安装了,因为第一次弄成一行,弄得时候libgtk2.0-dev 没装好报错了,导致后几个都没装上。
编译
cd到目录下,在新建的build目录下cmake后j就行
cd /home/lx/opencv-3.4.15
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.15/modules ..
make -j32
注意,cmke最后面试空格加两点!!电脑性能不好的-j后面的数字写小一点。
系统变量
sudo make install
sudo gedit /etc/ld.so.conf.d/opencv.conf
写入
/usr/local/lib
sudo gedit /etc/bash.bashrc
在最后面写入
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
source /etc/bash.bashrc