Install OpenCV 4.2.0.
■ Environment - Raspberry Pi 3 - g++ 4.9.2 - Python3.4.2
■ Prerequisites The following is installed - Git - cmake - GNU Make
■ Procedure
$ sudo nano /etc/dphys-swapfile
Change CONF_SWAPSIZE
from
100 to` `1024
.
/etc/dphys-swapfile
CONF_SWAPSIZE=1024
Reflect the changes.
$ sudo /etc/init.d/dphys-swapfile restart
$ sudo apt update
$ sudo apt install build-essential cmake git pkg-config libgtk-3-dev "libcanberra-gtk*"
$ sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev
$ sudo apt install libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev opencl-headers
$ git clone --branch 4.2.0 https://github.com/opencv/opencv.git
$ git clone --branch 4.2.0 https://github.com/opencv/opencv_contrib.git
$ mkdir <path-to-opencv>/opencv/build
$ cd <path-to-opencv>/opencv/build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D ENABLE_NEON=ON \
-D OPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=/<path-to-opencv>/opencv_contrib/modules \
-D BUILD_EXAMPLES=OFF ..
`Configuring done`
and `Generating done`
are displayed, and confirm that the process was completed normally.
$ make -j4
$ sudo make install
$ pkg-config --modversion opencv4
Output
4.2.0
$ python3 -c "import cv2; print(cv2.__version__)"
Output
4.2.0
■ Reference link How to Install OpenCV on Raspberry Pi 3 https://linuxize.com/post/how-to-install-opencv-on-raspberry-pi/
Recommended Posts