1.下载opencv4.5.0和opencv_contrib4.5.0源码
opencv_contrib4.5.0:
-
svn : svn://116.56.140.138/soft/opencv_contrib-4.5.0.zip
-
github:https://github.com/opencv/opencv_contrib/archive/4.5.0.zip
opencv4.5.0
-
svn:svn://116.56.140.138/soft/opencv-4.5.0.zip
-
github:https://github.com/opencv/opencv/archive/4.5.0.zip
2.编译cuda版的opencv
解压
-
unzip opencv-4.5.0.zip
-
unzip opencv_contrib-4.5.0.zip -d opencv-4.5.0
生成MakeFile文件
-
cd opencv-4.5.0
-
mkdir build
-
cd build
-
cmake
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D WITH_CUDA=ON \
-D CUDA_GENERATION="Auto" \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" \
-D WITH_CUBLAS=1 \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.5.0/modules \
-D BUILD_opencv_hdf=ON ..
执行MakeFile
cat /proc/cpuinfo |grep 'physical id'|sort -u|wc -l
cat /proc/cpuinfo |grep 'core id'|sort -u|wc -l
cat /proc/cpuinfo |grep 'processor'|sort -u|wc -l
-
make,其中-j表示最多允许多少个编译命令同时执行,一般是cpu核数的两倍
make -j20
make install
-
如果之前make失败了,再次make时必须clean build目录
make clean