Opencv3环境配置
一、安装依赖库
1、移除本地的通过apt-get安装的opencv:
sudo apt-get autoremove libopencv-dev python-opencv
2、安装编译工具:
sudo apt-get install cmake build-essential
3、安装gtk:
sudo apt-get install libgtk2.0-dev libgtkglext1-dev
4、gui:
sudo apt-get install libqt4-dev libpangox-1.0-dev libxmu-dev libxmu-headers
5、安装视频相关media I/O:
安装是有的库可能是比较老的,请按住系统报的错误,更改为最新的。
sudo apt-get install zlib1g-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev libgphoto2-2-dev
sudo apt-get install libdc1394-22 libdc1394-22-dev libavcodec-dev libavformat-dev libavresample-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev v4l-utils libxine2-dev libmp3lame-dev libfaac-dev yasm
6、linear algebra
sudo apt-get install libeigen3-dev
7、parallel computation
sudo apt-get install libtbb-dev ocl-icd-opencl-dev opencl-headers
8、python相关
sudo apt-get install python-dev python-numpy python3-dev python3-numpy
配置
在编译的时候,关于cmake的配置,可以参考下面的的代码,并根据自己的需要增减模块:
cd /opt/
sudo mkdir opencv
cd /opencv/extracted/path
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/opencv/ \
-DBUILD_DOCS=ON -DBUILD_EXAMPLES=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_TBB=ON -DWITH_XINE=ON \
-DPYTHON2_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; \
print(get_python_inc())") \
-DPYTHON2_INCLUDE_DIRS=$(python -c "from distutils.sysconfig import get_python_inc; \
print(get_python_inc())") \
-DPYTHON2_EXECUTABLE=$(which python) \
-DPYTHON2_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; \
print(get_python_lib())") \
-DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; \
print(get_python_inc())") \
-DPYTHON3_INCLUDE_DIRS=$(python3 -c "from distutils.sysconfig import get_python_inc; \
print(get_python_inc())") \
-DPYTHON3_EXECUTABLE=$(which python3) \
-DPYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; \
print(get_python_lib())") \
-DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include/ ..