1、首先安装一些编译工具
# 安装编译工具
sudo apt-get install build-essential
# 安装依赖包
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
# 安装可选包
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
2、下载opencv
https://github.com/opencv/opencv/archive/3.4.0.zip
3、编译安装
# 打开文件夹:
cd opencv-3.4.0
# 新建一个文件夹用于存放临时文件:
mkdir build
# 切换到该临时文件夹:
cd build
# 开始编译:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j16 # 开启线程 按照自己的配置
sudo make install -j16
4、补充一个问题, Cuda10编译opencv时,会出问题
/home/lehui/Documents/opencv-3.4.0/modules/cudacodec/srcprecomp.hpp:60:37: fatal error: dynlink_nvcuvid.h: No such file or directory
原因:cuda10 does not provided dynlink_nvcuvid.h any more.
解决办法:
1、下载nvidia-sdk,地址:
https://developer.nvidia.com/designworks/video_codec_sdk/downloads/v8.2-ga2
将其中的nvcuvid.h, cuviddec.h copy 到 /usr/local/cuda/include/;
2、将下面文件中
# opencv的modules目录下
modules/cudacodec/src/precomp.hpp
modules/cudacodec/src/frame_queue.hpp
modules/cudacodec/src/cuvid_video_source.hpp
modules/cudacodec/src/video_decoder.hpp
modules/cudacodec/src/video_parser.hpp
将上面的文件中的代码改为:
if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000
include <dynlink_nvcuvid.h>
else
include <nvcuvid.h>
endif
网友评论