在树莓派上更新opencv
时间: 2023-11-07 08:49:10 浏览: 110
在树莓派上更新 OpenCV 可以采取以下步骤:
1. 更新系统软件包,确保树莓派上的所有软件都是最新的:
```
sudo apt-get update
sudo apt-get upgrade
```
2. 安装必要的依赖:
```
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng-dev libwebp-dev libopenexr-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libdc1394-22-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
sudo apt-get install libgtk-3-dev libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
sudo apt-get install libatlas-base-dev liblapacke-dev gfortran
```
3. 下载 OpenCV 源代码:
```
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.2.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.5.2.zip
unzip opencv.zip
unzip opencv_contrib.zip
```
4. 编译并安装 OpenCV:
```
cd opencv-4.5.2
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.5.2/modules \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON ..
make -j4
sudo make install
sudo ldconfig
```
5. 检查 OpenCV 是否安装成功:
```
pkg-config --modversion opencv4
```
如果成功安装,则会显示 OpenCV 的版本号。
阅读全文