

Installing: /usr/local/bin/opencv_version The final step is to install compiled OpenCV files: sudo make install. When completed you will see something like below. If the compilation fails at some point, due to resources not available, run the make command again and the process will continue from where it stopped. The process will take some time, around 1 - 2 hours, depending on the Raspberry Pi model. Run make to start the compilation process: make -j4 Build files have been written to: /home/pi/opencv_build/opencv/build Set up the OpenCV build configuration with cmake: To it: mkdir -p ~/opencv_build/opencv/build & cd ~/opencv_build/opencv/build Once the repositories are cloned, create a temporary build directory, and change If you want to install an older version of OpenCV, navigate to both opencv and opencv_contrib directories and run git checkout. , navigate to it and clone the OpenCV and OpenCV contrib repositories from Github: mkdir ~/opencv_build & cd ~/opencv_build git clone git clone Īt the time of writing, the default version in the GitHub repositories is version 4.1.1. First, update the packages index and install the build tools and required dependencies: 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 sudo apt install python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev Save the file and run the following command for changes to take effect: sudo /etc/init.d/dphys-swapfile restart To verify the installation, import the cv2 module and print the OpenCV version:

The command above will install all packages necessary to run OpenCV. To install OpenCV Python module, run the following commands: sudo apt update sudo apt install python3-opencv At the time of writing, the version in the repositories is 3.2 which is not the latest version. The OpenCV Python module is available from the standard Raspbian repository. Installing OpenCV from the Raspbian Repositories # We’re assuming that you have Raspbian installed on your Raspberry Pi In this tutorial, we will explain how to install OpenCV on Raspberry Pi.

It is used for a very wide range of applications including medical image analysis, stitching street view images, surveillance video, detecting and recognizing faces, tracking moving objects, extracting 3D models and much more.Ĭan take advantage of multi-core processing and features GPU acceleration for real-time operation. OpenCV (Open Source Computer Vision Library) is an open-source computer vision library and has bindings for C++, Python, and Java.
