文章目錄
  1. 1. 安装Ope1nCV所需的库(编译器、必须库、可选库)
  2. 2. 从官网下载最新opencv3.0源码 opencv3.zip
  3. 3. 添加库路径并使库生效
  4. 4. 设置环境变量:
  5. 5. 测试OpenCV自带例子:

安装Ope1nCV所需的库(编译器、必须库、可选库)

GCC 4.4.x or later
CMake 2.6 or higher
Git
GTK+2.x or higher, including headers (libgtk2.0-dev)
pkg-config
Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
[optional] libtbb2 libtbb-dev
[optional] libdc1394 2.x
[optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev

1
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

从官网下载最新opencv3.0源码 opencv3.zip

1
2
3
4
sudo unzip opencv3.zip  #解压
sudo cmake . #编译
sudo make
sudo make install

添加库路径并使库生效

1
2
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'  
sudo ldconfig

设置环境变量:

1
sudo gedit /etc/bash.bashrc

添加内容:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

测试OpenCV自带例子:

1
2
3
4
5
cd samples
sudo cmake .
sudo make -j $(nproc) #
cd cpp
sudo ./cpp-example-facedetect ../data/lena.jpg

出现图像以及面部识别区域,说明OpenCV安装成功!

result

文章目錄
  1. 1. 安装Ope1nCV所需的库(编译器、必须库、可选库)
  2. 2. 从官网下载最新opencv3.0源码 opencv3.zip
  3. 3. 添加库路径并使库生效
  4. 4. 设置环境变量:
  5. 5. 测试OpenCV自带例子: