ubuntu18 build opencv4 from source

1 安装依赖

## Install dependencies
sudo apt -y install build-essential checkinstall cmake pkg-config yasm
sudo apt -y install git gfortran
sudo apt -y install libjpeg8-dev libpng-dev

sudo apt -y install software-properties-common
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt -y update

sudo apt -y install libjasper1
sudo apt -y install libtiff-dev

sudo apt -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev
sudo apt -y install libxine2-dev libv4l-dev
cd /usr/include/linux
sudo ln -s -f ../libv4l1-videodev.h videodev.h
cd ~ sudo apt -y install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev sudo apt -y install libgtk2.0-dev libtbb-dev qt5-default sudo apt -y install libatlas-base-dev sudo apt -y install libfaac-dev libmp3lame-dev libtheora-dev sudo apt -y install libvorbis-dev libxvidcore-dev sudo apt -y install libopencore-amrnb-dev libopencore-amrwb-dev sudo apt -y install libavresample-dev sudo apt -y install x264 v4l-utils # Optional dependencies sudo apt -y install libprotobuf-dev protobuf-compiler sudo apt -y install libgoogle-glog-dev libgflags-dev sudo apt -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

# Python dependencies
sudo apt -y install python3-dev python3-pip sudo -H pip3 install -U pip numpy sudo apt -y install python3-testresources

2 编译
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=./install \
    -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D BUILD_opencv_python2=OFF \
    -D BUILD_opencv_python3=ON \
    -D WITH_CUDA=ON \
    -D BUILD_opencv_cudacodec=OFF \
    -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.1 \
    -D CUDA_ARCH_BIN="6.0 6.1 7.0 7.5" -D CUDA_ARCH_PTX="" \
    -D INSTALL_C_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON .. make -j4

posted on 2021-01-11 12:28  gris  阅读(183)  评论(0编辑  收藏  举报

导航