文章目录
- opencv下载
opencv下载地址 - 安装opencv的依赖库
sudo apt-get install libopencv-dev python-opencv
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
- 编译准备,在下载的opencv文件夹内新建build文件夹并进入
cd opencv
mkdir build
cd build
- 编译
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install
- 至此,opencv编译完成,调用的时候库文件以及头文件均在、usr/local/文件夹下
- opencv的环境配置
#创建opencv的配置文件并编辑
sudo gedit /etc/ld.so.conf.d/opencv.conf
#添加内容/usr/local/lib
#配置文件生效
sudo ldconfig
#配置环境变量
sudo gedit ~/.bashrc
# 添加opencv的配置路径
#opencv
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
#环境变量生效
source ~/.bashrc
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/134f5cda5b3e14b767bf8c8c452215b1.png#pic_center)