ubuntu20.04OpenCV4.5.0
时间: 2023-10-28 07:58:59 浏览: 105
OpenCV-4.5.1
您好!对于在Ubuntu 20.04上安装OpenCV 4.5.0,您可以按照以下步骤进行操作:
1. 更新系统:
```
sudo apt update
sudo apt upgrade
```
2. 安装依赖项:
```
sudo apt 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
```
3. 下载OpenCV源码:
```
cd ~
mkdir opencv_build
cd opencv_build
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.5.0
```
4. 创建并进入build目录:
```
mkdir build
cd build
```
5. 配置编译选项:
```
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
..
```
6. 编译和安装:
```
make -j$(nproc)
sudo make install
sudo ldconfig
```
完成以上步骤后,您应该成功安装了OpenCV 4.5.0。您可以通过编写简单的测试代码来验证安装是否成功。希望对您有所帮助!如果您还有其他问题,请随时提问。
阅读全文