安装opencv4.6
时间: 2023-10-20 21:30:34 浏览: 145
opencv-4.6.0
安装OpenCV 4.6的步骤如下:
1. 安装依赖项
```
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libeigen3-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common libtesseract-dev libopenexr-dev libgdal-dev libgflags-dev libgoogle-glog-dev libprotobuf-dev protobuf-compiler libgphoto2-dev libhdf5-dev libhdf5-serial-dev libatlas-base-dev libjasper-dev libprotobuf-dev protobuf-compiler
```
2. 下载OpenCV 4.6
```
cd ~/
mkdir opencv
cd opencv
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.6.0
cd ..
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout 4.6.0
cd ..
```
3. 编译和安装OpenCV 4.6
```
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv/opencv_contrib/modules -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUDA=ON -D WITH_CUBLAS=1 -D WITH_LIBV4L=ON -D WITH_V4L=ON -D WITH_GTK=ON -D WITH_OPENGL=ON -D BUILD_opencv_python3=ON -D BUILD_opencv_python2=OFF ..
make -j$(nproc)
sudo make install
sudo ldconfig
```
4. 验证OpenCV 4.6的安装
```
pkg-config --modversion opencv4
```
如果输出版本号(例如 4.6.0),说明安装成功。
阅读全文