opencv安装教程ubuntu
时间: 2024-03-19 11:39:15 浏览: 70
Opencv安装教程
5星 · 资源好评率100%
在Ubuntu上安装OpenCV可以按照以下步骤进行:
1. 更新系统软件:
```
sudo apt update
sudo apt upgrade
```
2. 安装必要的依赖项:
```
sudo apt install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt 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 <version> # 替换<version>为你想要安装的OpenCV版本号,例如:4.5.2
```
4. 创建并进入一个用于构建OpenCV的目录:
```
mkdir build
cd build
```
5. 使用CMake配置构建选项:
```
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
```
6. 编译OpenCV:
```
make -j$(nproc)
```
7. 安装OpenCV:
```
sudo make install
```
8. 配置动态链接库:
```
sudo /bin/bash -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
```
至此,OpenCV已经成功安装在你的Ubuntu系统上了。
阅读全文