当前位置:   article > 正文

Linux系统安装OpenCV_linux如何安装opencv

linux如何安装opencv

Introduction

This post introduces two ways of installing OpenCV on the Linux system (Ubuntu).

Option 1: Install OpenCV through the source

Step 1: Install build tools

sudo apt install build-essential cmake git pkg-config libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
gfortran openexr libatlas-base-dev \
libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Step 2: Clone OpenCV’s repositories

mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv.git
# optional
git clone https://github.com/opencv/opencv_contrib.git
  • 1
  • 2
  • 3
  • 4

Step 3: Setup OpenCV build

cd ~/opencv_build/opencv
mkdir -p build && cd build
  • 1
  • 2
# remove some options according to your personal favor
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

Step 4: Start a compilation

make -j 8
  • 1

Step 5: Install OpenCV

# install
sudo make install
  • 1
  • 2
# verify if success
pkg-config --modversion opencv4
  • 1
  • 2

Option 2: Installation of OpenCV using the Ubuntu repository

Please refer to [1].

Reference

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/623374
推荐阅读
相关标签
  

闽ICP备14008679号