Ubuntu 安装 opencv
时间: 2023-11-04 17:54:24 浏览: 118
可以通过以下步骤在 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
```
3. 安装图像和视频 I/O 库:
```
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libv4l-dev libxvidcore-dev libx264-dev
```
4. 安装 Python3 支持:
```
sudo apt-get install python3-dev python3-pip python3-numpy
```
5. 下载 OpenCV 源代码:
```
git clone https://github.com/opencv/opencv.git
```
6. 切换到下载的目录,创建 build 目录并进入:
```
cd opencv
mkdir build
cd build
```
7. 配置编译:
```
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
```
8. 编译和安装:
```
make -j4
sudo make install
```
9. 配置库路径:
```
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
```
现在,OpenCV 库已经安装成功。
阅读全文