ubuntu安装opencv4 opencv_contrib
时间: 2023-11-04 20:21:34 浏览: 131
你可以按照以下步骤在Ubuntu上安装OpenCV4和opencv_contrib:
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 libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libv4l-dev
sudo apt install libxvidcore-dev libx264-dev libatlas-base-dev gfortran libblas-dev liblapack-dev
```
3. 克隆OpenCV和opencv_contrib的源代码:
```
cd ~
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
```
4. 编译和安装OpenCV4:
```
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
make -j$(nproc)
sudo make install
sudo ldconfig
```
5. 安装完成后,可以通过以下命令检查OpenCV版本:
```
pkg-config --modversion opencv4
```
现在你已经成功在Ubuntu上安装了OpenCV4和opencv_contrib。请记住,这个过程可能会花费一些时间,具体取决于你的系统配置和网络速度。祝你好运!
阅读全文