2020年4月24日 星期五

[RPi] 安裝 OpenCV 3 在 Pi 上(Raspbian Buster)

# 安裝必要套件
```
sudo apt-get update
sudo apt-get install -y build-essential cmake pkg-config
sudo apt-get install -y libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install -y libxvidcore-dev libx264-dev
sudo apt-get install -y libgtk2.0-dev libgtk-3-dev
sudo apt-get install -y libatlas-base-dev gfortran
sudo apt-get install -y python3-dev python3-pip
sudo apt-get install -y python3-numpy python3-scipy python3-matplotlib
```


# 下載 OpenCV 3.4.10
```
wget https://github.com/opencv/opencv_contrib/archive/3.4.10.tar.gz -O opencv_contrib-3.4.10.tar.gz
tar zxvf opencv_contrib-3.4.10.tar.gz

wget https://github.com/opencv/opencv/archive/3.4.10.tar.gz
tar zxvf 3.4.10.tar.gz

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH=/home/pi/opencv_contrib-3.4.10/modules \
    -D BUILD_EXAMPLES=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFP3=ON ..

time make -j4 VERBOSE=1
```

沒有留言: