Install Open-CV and Python on Raspbian

I found it the hard way that it’s very complicated to compile and install Open-CV on Raspberry Pi. I always run into some weird errors. It’s either some dependencies are not met or even more stressfully: my 8GB SDCard has not enough free space to compile Open-CV from source. Why all the hassles if all I want is a working version of Open-CV and Python together on Raspbian for my beloved Raspberry 3? Yes, maybe in the future, when I really really need to compile Open-CV with differents Build settings, I may do that. But for now, normal is good as long as I can install it.

When I try compile Open-CV on Raspbian PIXEL version (the full desktop version with many bloat-wares), there’s obviously not enough free space. So I skimmed it some more by remove Wolfram Engine, Python games and stuffs like that. Just not enough!

1. Download and install Raspbian Jessie Lite version to my SDCard.
This step is easy and straight forward.
Just use dd command.
2. Install GUI and Desktop manager:
I choose PIXEL over others because it’s lighter.
When I have PIXEL installed, there’s no need to install LightDM because it is
already in the packet.
3. Install Open-CV from deb package.

sudo apt-get update
sudo apt-get upgrade
sudo rpi-update 

For OpenCV to process image:

sudo apt-get install libtiff5-dev libjasper-dev libpng12-dev 

For OpenCV to process video:

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

Install GTK for GUI stuffs:

sudo apt-get install libgtk2.0-dev 

Others package:

sudo apt-get install libatlas-base-dev gfortran
sudo python 

Install Numpy using pip:

sudo pip install numpy 

Now actually install OpenCV from DEB:

wget ""
sudo dpkg -i latest-OpenCV.deb 

when done, to test if we really have OpenCV install, in python, do this:

import cv2

will show you OpenCV version.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s