1.更新系统

sudo apt-get update
sudo apt-get upgrade

2.安装编译工具和依赖包

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

3.下载opencv并解压

网址:https://opencv.org/releases.html

mkdir opencv
cd opencv
unzip 3.2.0.zip

4.编译安装OpenCV

mkdir build 
cd build 
cmake ..  #默认设置
make -j7# 多线程执行make任务
sudo make install 

5.添加OpenCV库添加到路径(没有opencv.conf文件会自动创建)

sudo gedit /etc/ld.so.conf.d/opencv.conf

6.在文件中添加

/usr/local/lib

执行如下命令使配置路径生效

sudo ldconfig

7.配置bash

sudo gedit /etc/bash.bashrc

在最末尾添加

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

保存,执行如下命令使得配置生效

source /etc/bash.bashrc
sudo updatedb

8.测试opencv

找到~/opencv-3.2.0/samples/cpp/example_cmake目录

mkdir build
cd build
cmake ..
make
./opencv_example

至此完成配置

 

 

 

 

 

posted on 2019-01-15 21:38  柠檬檬檬  阅读(161)  评论(0编辑  收藏  举报