安装Opencv

Step 1: 创建目录

mkdir opencv
cd /opencv/

Step 2: 移除之前安装的 ffmpeg 和 x264
sudo apt-get -qq remove ffmpeg x264 libx264-dev
Step 3: 安装相关依赖
sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

安装ffmpeg

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg gstreamer0.10-ffmpeg
Step 4: 下载和解压opencv
下载opencv_contrib-master,opencv-3.1.0
对应的Github路径如下:
https://github.com/Itseez/opencv/
https://github.com/Itseez/opencv_contrib
解压opencv_contrib-master,opencv-3.1.0
其中opencv_contrib是一些为引入到主版本上的新特性,为了学习这些新特性最好也将它安装上。
cd opencv-3.1.0
Step 5: Begin Build Process

Note that this bit would take some time to complete

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -DOPENCV_EXTRA_MODULES_PATH=/home/jimmy/Desktop/opencv_contrib-master/modules /home/jimmy/Desktop/opencv-3.1.0 ..

这里注意的是这里的/home/jimmy/Desktop/opencv_contrib-master/modules是步骤4中下载的opencv_contrib-master下的module 目录,
/home/jimmy/Desktop/opencv-3.1.0为步骤4中下载的opencv-3.1.0目录,这个是为了安装opencv_contrib而添加的。

编译安装

make -j5
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

重启电脑

Contents
  1. 1. 安装Opencv
    1. 1.1. Step 1: 创建目录
    2. 1.2. Step 2: 移除之前安装的 ffmpeg 和 x264
    3. 1.3. Step 3: 安装相关依赖
  2. 2. 安装ffmpeg
    1. 2.1. Step 4: 下载和解压opencv
    2. 2.2. Step 5: Begin Build Process