Ubuntu下编译安装OpenCV
sudo apt install build-essential ffmpeg ccache libopenblas-openmp-dev \
libgtk-3-dev libgtkglext1-dev libavcodec-dev libavformat-dev libdc1394-dev \
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
libjpeg-dev libtiff-dev libswscale-dev libpng-dev libavresample-dev \
libeigen3-dev libtbb-dev
sudo ln -s /usr/include/lapacke.h /usr/include/x86_64-linux-gnu
wget -O opencv.tar.gz https://hub.fastgit.org/opencv/opencv/archive/refs/tags/4.5.5.tar.gz
wget -O crontrib.tar.gz https://hub.fastgit.org/opencv/opencv_contrib/archive/refs/tags/4.5.5.tar.gz
tar -xzf opencv.tar.gz
tar -xzf crontrib.tar.gz
find opencv_contrib-4.5.5/ -name CMakeLists.txt -exec sed -i 's|raw.githubusercontent.com|raw.githubusercontents.com|g' {} \;
find opencv_contrib-4.5.5/ -name download*.cmake -exec sed -i 's|raw.githubusercontent.com|raw.githubusercontents.com|g' {} \;
cd opencv-4.5.5
sed -i 's|raw.githubusercontent.com|raw.githubusercontents.com|g' 3rdparty/ippicv/ippicv.cmake
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=DEBUG -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_GENERATE_PKGCONFIG=ON\
-D WITH_FFMPEG=ON -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_LAPACK=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON -D BUILD_JAVA=OFF -D BUILD_opencv_python3=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.5.5/modules" ..
# -D WITH_IPP=ON -D WITH_OPENMP=ON -D WITH_CUDA=ON -D OPENCV_DNN_CUDA=ON
make -j4
make install
make clean
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_GENERATE_PKGCONFIG=ON\
-D WITH_FFMPEG=ON -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_LAPACK=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON -D BUILD_JAVA=OFF -D BUILD_opencv_python3=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.5.5/modules" ..
make -j4
make install
本文版权,除注明引用的部分外,归作者所有。本文严禁商业用途的转载。非商业用途的转载需在网页明显处署上作者名称及原文链接。