ubuntu安装opencv3.4.6
时间: 2023-11-09 11:49:29 浏览: 185
以下是在 Ubuntu 上安装 OpenCV 3.4.6 的步骤:
1. 更新系统软件包:
```
sudo apt-get update
sudo apt-get upgrade
```
2. 安装依赖项:
```
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
```
3. 下载 OpenCV 3.4.6:
```
cd ~
mkdir opencv
cd opencv
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.6.zip
unzip opencv.zip
```
4. 下载 OpenCV 3.4.6 的 contrib 模块:
```
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.4.6.zip
unzip opencv_contrib.zip
```
5. 编译和安装 OpenCV 3.4.6:
```
cd opencv-3.4.6
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.6/modules ..
make -j4
sudo make install
```
6. 验证 OpenCV 是否安装成功:
```
pkg-config --modversion opencv
```
如果输出 `3.4.6`,则说明 OpenCV 安装成功。
注意:以上步骤仅适用于 Ubuntu 18.04 LTS,其他版本可能需要略微调整。
阅读全文