Ubntu安装opencv
时间: 2023-11-13 14:58:18 浏览: 63
好的,以下是在 Ubuntu 上安装 OpenCV 的步骤:
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 python3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
```
3. 下载 OpenCV 源代码:
```
cd ~
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.5.1
```
4. 编译和安装 OpenCV:
```
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j$(nproc)
sudo make install
```
5. 验证安装:
```
pkg-config --modversion opencv4
```
如果输出了 OpenCV 的版本号,则说明安装成功。
阅读全文