In this post I want to show you how to install OpenCV 3.2.0 on you Raspberry Pi Zero W.
Attention:
- Installing OpenCV on your Raspberry Pi Zero W takes more than 9h. So I recommend to do this over night
Preconditions:
- Make sure you installed Raspbian Jessie on your Raspberry Zero W
Installing OpenCV on your Raspberry Pi Zero W
1. Expand Filesystem
If your filesystem is not expanded, expand it by typing
2. Install dependencies
I will keep the description short for the following shell commands to keep the tutorial short. I think you want to start as soon as possible with OpenCV on your Raspberry Pi Zero W.
Execute the following shell commands:
3. Download OpenCV 3.2.0
4. Setup Python for OpenCV
5. Compile and install OpenCV 3.2.0 for Raspberry Pi Zero W
These command takes more than 9 hours because the hardware of the Raspberry Pi Zero W is slow. Moreover the Zero W will build OpenCV with only one core.
Congratulation, OpenCV, you have successfully installed OpenCV on your Raspberry Pi Zero W!
1. Expand Filesystem
If your filesystem is not expanded, expand it by typing
$ sudo raspi-configin terminal and, choose the option "Expand Filesystem", enter with finish and restart your Pi.
2. Install dependencies
I will keep the description short for the following shell commands to keep the tutorial short. I think you want to start as soon as possible with OpenCV on your Raspberry Pi Zero W.
Execute the following shell commands:
//Update and upgrade your system$ sudo apt-get update
$ sudo apt-get upgrade
//Install dev-tools
$ sudo apt-get install build-essential cmake pkg-config
//Download image I/O packages and install them
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
//Download video I/O packages for video processing
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev
//GTK dev library for OpenCV
$ sudo apt-get install libgtk2.0-dev
//Optimize packages for OpenCV
$ sudo apt-get install libatlas-base-dev gfortran
//Install Python 2.7 header
$ sudo apt-get install python2.7-dev
3. Download OpenCV 3.2.0
//Download OpenCV 3.2.0 from GitHub
$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip
$ unzip opencv.zip
//Download "opencv_contrib" repo for OpenCV 3.2.0
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.2.0.zip
$ unzip opencv_contrib.zip
//Optional: Free some disk space and delete not needed zipped files
$ rm opencv.zip opencv_contrib.zip
4. Setup Python for OpenCV
//Install Python package manager for OpenCV
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
//Download NumPy to build Python and OpenCV bindings
$ pip install numpy
5. Compile and install OpenCV 3.2.0 for Raspberry Pi Zero W
//Setup build by using CMake
$ cd ~/opencv-3.2.0/
$ mkdir build
$ cd build
$ 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=~/opencv_contrib-3.2.0/modules \
-D BUILD_EXAMPLES=ON ..
These command takes more than 9 hours because the hardware of the Raspberry Pi Zero W is slow. Moreover the Zero W will build OpenCV with only one core.
//Build OpenCV on Raspberry Pi Zero WIf OpenCV is 100% build without any error, you can install it on your Raspberry Pi Zero W quickly.
$ make
//Install OpenCV on Raspberry Pi Zero W
$ sudo make install
$ sudo ldconfig
Congratulation, OpenCV, you have successfully installed OpenCV on your Raspberry Pi Zero W!
Keine Kommentare:
Kommentar veröffentlichen