1. 下载opencv-3.4.3和opencv_contrib-3.4.3
opencv的下载地址:https://github.com/opencv/opencv/
opencv_contrib的下载地址:https://github.com/opencv/opencv_contrib.git
选择相应版本下载即可。
2. 解压后将opencv_contrib-3.4.3移动到opencv-3.4.3中。
3. 安装依赖项
sudo apt-get update sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev sudo apt-get install -y python2.7-dev sudo apt-get install -y python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp sudo apt-get install -y curl sudo apt-get update
在安装依赖项时,如果提醒某一项无法定位,就在命令中把该项删除,再安装,否则该命令的其他项没有安装就退出了。
4. 在opencv-3.4.3文件夹下打开终端,输入以下命令
mkdir release cd release/ cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="7.2" -D CUDA_ARCH_PTX="" -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local OPENCV_EXTRA_MODULES_PATH=~/path/opencv-3.4.3/opencv_contrib-3.4.3/modules .. make -j8 sudo make install
5. 等待完成。