The Intel demo team at CES posing with some of the awards the Edison won.

The Intel demo team at CES posing with some of the awards the Edison won.

Computer vision is a processor-demanding task, but thanks to a dual-core Atom processor, the Intel Edison handles it with ease. The Edison ships with a highly custom Linux image, but you’ll only need to add a few software packages and custom code to get OpenCV — a wildly popular approach to computer vision — operational and recognizing human faces in photos.

1. Flash the Edison with the Latest Firmware

Follow the flashing instructions on the Intel documentation page at update your Edison with the latest image.

Then run the Edison configuration script:

configure_edison --setup

And follow the setup prompts to configure a hostname and root password and to set up Wi-Fi access.

2. SSH into the Edison

On Windows, download and install Putty, an SSH client. Then point Putty to your Edison.

On OSX or Linux, open a terminal and type:

ssh [email protected]

NOTE: If you changed the hostname, replace edison in this address with the new name you created.

3. Install the latest IoT Developer Kit Libraries

Type in the following commands, and note this is actually one long line with spaces between intel-iotdk and the URL, and on both sides of the > character:

echo "src intel-iotdk" > /etc/opkg/intel-iotdk.conf

Update the package repository, then upgrade all the packages:

opkg update

opkg upgrade

4. Add an Unofficial Package Repository

Access to every package is not available without adding repository locations to the opkg/base-feeds.conf file. By doing this, you’ll add an enormous number of compiled applications, saving you the hassle of compiling from source.

NOTE: Unofficial repositories are quite common across most Linux distributions.

Add the following lines to base-feeds.conf:

echo "src/gz all

src/gz edison

src/gz core2-32" >> /etc/opkg/base-feeds.conf

Update the repository index again, since you just added new package locations:

opkg update

Next, install NumPy, OpenCV, and OpenCV-Python.

opkg install python-numpy opencv python-opencv nano

That’s it! All the necessary packages are installed. Time to start hacking code!

NOTE: Installing the basic text editor nano is not necessary, but is suggested unless you’re comfortable using vi.

5. Programming with Python and OpenCV

Launch nano and specify a filename to use. Then import the 3 required Python libraries:

nano ~/

import numpy

import cv2

import urllib

Download and place our sample photo in the Edison’s web server directory with the new filename, in.jpg.

print("Downloading Images and Necessary Files")

urllib.urlretrieve(, '/usr/lib/edison_config_tools/public/in.jpg')

Next, download the XML file that defines the parameters for the OpenCV facial-recognition algorithm. This file is also saved to the public directory of the Edison’s web server as haarcascade_frontal face_alt.xml.

urllib.urlretrieve('', '/usr/lib/edison_config_tools/public/haarcascade_frontalface_alt.xml')

Import the photo using OpenCV and convert it to grayscale for use in the facial-recognition process:

img = cv2.imread('/usr/lib/edison_config_tools/public/in.jpg')

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

Using the OpenCV libraries, create the facial-recognition algorithm and process the grayscale image:

faceCascade =


faces =


minSize=(30, 30), flags =

The faces variable now contains an array of rectangular coordinates that surround each face that OpenCV found in the image. These coordinates are then used to draw a box around each face in the original color image, which you’ll save as a new file:

for (x,y,w,h) in faces:



Finally, save the text file by pressing Ctrl-X on your keyboard. When prompted to save the file, type Y and Enter.

6. Web page Setup

Download a simple HTML file which will display the pre- and post-processed images on the Edison’s onboard web server.


Change directories to the web server’s public directory:

cd /usr/lib/edison_config_tools/public

7. Viewing the Images

Now head on over to http://edison.local/OpenCV.html to view the Before and After images, with a box around each detected face!

Going Further

Now that OpenCV and Python are configured on your Edison, be sure to see the official documentation for great example code and ideas at OpenCV can detect all kinds of shapes, analyze video, and much more.