ubuntu20.04下安装opencv3.4.0和扩展包怎么安装
时间: 2024-01-21 09:03:51 浏览: 188
ubuntu下安装opencv步骤
以下是在Ubuntu 20.04下安装OpenCV 3.4.0和扩展包的步骤:
1. 安装依赖项
在终端中运行以下命令:
```
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python3.8-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
```
2. 下载OpenCV源代码
在终端中运行以下命令:
```
mkdir ~/opencv
cd ~/opencv
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 3.4.0
```
3. 编译和安装OpenCV
在终端中运行以下命令:
```
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j$(nproc)
sudo make install
```
4. 安装OpenCV扩展包(可选)
如果需要安装OpenCV扩展包,可以使用以下命令:
```
cd ~/opencv
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout 3.4.0
cd ~/opencv/opencv/build
cmake -DOPENCV_EXTRA_MODULES_PATH=~/opencv/opencv_contrib/modules ..
make -j$(nproc)
sudo make install
```
完成上述步骤后,OpenCV 3.4.0及其扩展包已经成功安装在您的Ubuntu 20.04系统上。
阅读全文