1.安装依赖项
1. 1安装必备包
sudo apt-get install build-essential cmake libjpeg-dev libtiff5-dev libjasper-dev
1.1安装gtk
for opencv3.2 and above:
sudo apt-get install libgtk-3-dev
for opencv2.4.x:
sudo apt-get install libgtk2.0-dev
1.2 安装v4l2
sudo apt-get install v4l2ucp v4l-utils libv4l-dev
1.3安装ffmpeg
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libavresample-dev
1.4安装gstreamer(for opencv3.2 and above):
sudo apt-get install libgstreamer1.5-dev libgphoto2-dev
2. 编译
cd opencv2.4.13/build
linux:
cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF ..
arm:
cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_GENERATION=Kepler ..
make -j4
sudo make install
3. 配置环境
3.1 打开/etc/ld.so.conf.d/opencv.conf,在末尾加入/usr/local/lib
sudo gedit /etc/ld.so.conf.d/opencv.conf sudo ldconfig
3.2 编辑/etc/profile,
sudo gedit /etc/profile
追加
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
使修改生效
source /etc/profile