ubuntu20.04安装opencv4.5.3
时间: 2023-04-27 22:06:34 浏览: 320
opencv 4.5.3安装包及依赖包
安装 OpenCV 4.5.3 on Ubuntu 20.04:
1. 安装所需的依赖项:
```
sudo apt-get update
sudo apt-get install build-essential cmake git pkg-config libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
gfortran openexr libatlas-base-dev python3-dev python3-numpy \
libtbb2 libtbb-dev libdc1394-22-dev
```
2. 下载 OpenCV 源代码:
```
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.5.3
```
3. 创建并进入 build 目录:
```
mkdir build
cd build
```
4. 配置和生成:
```
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D PYTHON_EXECUTABLE=$(which python3) ..
make -j$(nproc)
```
5. 安装:
```
sudo make install
```
6. 更新动态链接器:
```
sudo ldconfig
```
7. 检查安装是否成功:
```
python3 -c "import cv2; print(cv2.__version__)"
```
输出版本号(例如 4.5.3)即表示安装成功。
阅读全文