Install OpenCV 4.4 on Raspberry Pi

 I often work with OpenCV in Raspberry Pi or the Jetson series. In the NVidia Jetson series, OpenCV is optimized and comes with the Jetpack installation. As a result, you do not need to install OpenCV separately.

However, because Raspberry Pi OS is not installed with OpenCV, users must install it themselves. Unlike the Jetson series, Raspberry Pi has no GPU to use Cuda. The Mali GPU, used by Raspberry Pi, is used only for graphics and is difficult to use in OpenCV to speed up the OpenCV processing speed. Therefore, OpenCV used by Raspberry Pi does not require special optimization. Therefore, it is less necessary to build and use the source code. The case of building the source code is probably when you need the latest version of OpenCV. If you want to use an already verified version rather than the latest version, you can easily install it by following the steps below.


Install Raspberry Pi OS on the Rpi4B

I will use Raspberry Pi 4 B+ 2GB memory model and the OS will use Raspberry Pi OS. There are three types of OS in the picture below, one of which is "Raspberry Pi OS with desktop."

The OS installation method is omitted because there are numerous web documents or YouTube videos. After installing the OS, make sure to set up Ethernet or WiFi so that you can connect to the Internet.


Install necessary modules and OpenCV

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  libgtk2.0-dev libgtk-3-dev  libatlas-base-dev gfortran

sudo apt-get install -y openexr libqtgui4 libqt4-test
sudo apt-get install -y python3-dev python3-pip
sudo  pip3 install opencv-python
 


Now verify that it is installed correctly.

root@raspberrypi:~# python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> import numpy as np
>>> cv2.__version__
'4.4.0'

You can check that OpenCV and numpy are installed without any problems. 


Wrapping up

As of December 2020, the OpenCV version, which can be installed using the pip command, is 4.40. Perhaps this version value will continue to be updated.






댓글

이 블로그의 인기 게시물

Image Processing #7 - OpenCV Text

Playing YouTube videos using OpenCV

OpenCV Installation - Rasbian Buster, Jessie, DietPi Buster