ubuntu18.04安装OpenCV
时间: 2023-10-12 07:01:55 浏览: 136
好的,以下是在Ubuntu 18.04上安装OpenCV的步骤:
1. 打开终端,更新源列表
```
sudo apt-get update
```
2. 安装OpenCV依赖项
```
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
```
3. 安装Python依赖项(如果需要Python支持)
```
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
```
4. 下载OpenCV
```
cd ~
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.5.3
```
5. 编译和安装OpenCV
```
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j4
sudo make install
```
6. 验证OpenCV是否正确安装
```
pkg-config --modversion opencv4
```
如果安装成功,会输出OpenCV的版本号。
希望这些步骤可以帮助你在Ubuntu 18.04上安装OpenCV。
阅读全文