Skip to content
Roberto edited this page Oct 14, 2017 · 13 revisions

Setup

Execute:

Set memory partition in order to maximize CPU RAM:

sudo raspi-config => Advanced options and set gpu memory to 16MB (from te predefined 128MB)

Install build tools:

sudo apt-get install build-essential git cmake pkg-config

Install packages used to load various image formats from disk:

sudo apt-get install libtiff4-dev libjasper-dev libpng12-dev libjpeg-dev

Install required video I/O packages:

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

[Optional] Install GTK, for opencv gui operations:

sudo apt-get install libgtk2.0-dev

[Optional] Install optimized matrix operation libraries

sudo apt-get install libatlas-base-dev gfortran

Install Tesseract and Leptonica

sudo apt-get install tesseract-ocr tesseract-ocr-eng libtesseract-dev libleptonica-dev

Install zbar (QR Code support)

sudo apt-get install python-zbar

Clone OpenCV 3.3 from repository:

cd ~

git clone https://github.com/Itseez/opencv.git

cd opencv

git checkout 3.3.0

Clone opencv_contrib repo:

cd ~

git clone https://github.com/Itseez/opencv_contrib.git

cd opencv_contrib

git checkout 3.3.0

Install numpy:

sudo apt-get install python-numpy

Install Pillow (PIL)

sudo pip install pillow

Install PiCamera

sudo apt-get install python-picamera

Configure OpenCV build:

cd ~/opencv

mkdir build

cd 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_EXTRA_MODULES_PATH=~/opencv_contrib/modules \

-D BUILD_EXAMPLES=OFF ..

Build OpenCV:

make -j2

Install OpenCV:

sudo make install

Remove source files

cd ~

rm -rvf opencv*

Reset memory partition

sudo raspi-config => Advanced options and reset gpu memory to 128MB