SimpleCV on the RPi

SimpleCV on the RPi

Introduction – keep your eye on the ball

What is CV, or Computer Vision?  A search online will give you a definition, “Computer vision is a field that includes methods for acquiring, processing, analyzing, and understanding images and, in general, high-dimensional data from the real world in order to produce numerical or symbolic information, e.g., in the forms of decisions…”

Basically, it is using any image sensor to influence the action of a computer.  There are some fundamental sensors that will provide this such as a photo resistor or IR proximity sensor.  I’ve used these types of vision sensors with micro controllers to trigger alarms and take action before.  But CV is a bit more sophisticated than that.

The RPi can do the fundamental light sensor tasks like its micro controller counter parts.  However, it is more adapt at processing complex data from array sensors like camera modules and line scanners.  This is were processing tools like OpenCV and Simple CV come into play.

OpenCV was developed by Intel at their Russian research facility in Nizhny Novgorod.  Here is a video from Francesco Piscani detailing the install steps, of which I validated.

The installation of OpenCV on the RPi is a time consuming effort, in contrast to SimpleCV.  For this reason, I’ll be focusing my efforts on this post towards the SimpleCV development platform.

SimpleCV is the work of the team at Sight Machine.  They specialize in manufacture automation using computer aided visual inspection systems.  This article in Wired shows why they are in the business of CV.

The commonality of CV is taking images from camera sensors and processing the data to determine a logical state.  This logical state can be used to determine a course of action.

Intent – eye of the beholder

How can CV be used?  Some of the more basic uses are for security and identification.  There are numerous examples of face tracking, parking enforcement, or license plate identification online.  One of the most clever uses I found online was a developer’s effort to keep his local bird population fed.

Details – eye of the tiger

Lets dive in and get SimpleCV installed.  You can get the steps to do that here.  But I want to write them up as well in the event of changes.

1. Run this command to install the core dependencies.

sudo apt-get install ipython python-opencv python-scipy python-numpy python-setuptools python-pip

2. SimpleCV should now be ready to install. Download SimpleCV from github and install from the source.

sudo pip install

3. I found that I had to run one more dependency

sudo pip install svgwrite

4. SimpleCV should be all set up. Connect a compatible camera to the board’s usb input and open up the simplecv shell by typing in this command.


How simple was that!?  Now we can move on to some examples, but before we do I would like to install the ability to play media files.  We’ll install mplayer using this command.

sudo apt-get install mplayer

Once that is installed, you can verify it works using a sample video.  I used the one suggested by Adafruit for the TFT demo.  So on toward the examples.  The first one I tried was the “” example that the SimpleCV folks provide online.  If all goes well, you should see an image with the words “Hello World” in the upper left corner.  On my instance, I noticed that the image was choppy and the color level of the camera was black and white.  So I back tracked a bit and tried some earlier examples.

My results were more of what I expected when ran inside the simplecv console, this is done by opening a terminal and entering “simplecv” at the prompt.  Then you can enter in the following code.

SimpleCV:1> cam = Camera()
SimpleCV:1> img = cam.getImage()

You can find this example and more on the SimpleCV tutorial site.

Relevance – I’ll be watching you

What can we do with CV?  That answer is left to the imagination.  I’ve seen several examples of traffic and security applications.  It’s development into the SimpleCV package was brought about by a group interested in quality assurance applications.  How would I apply this to my bike rides?  I don’t know.  One idea that plays into the theme of this years instruction is to use it for augmented reality.  It’s possible for me to plot the conditions of a bike route, like surface conditions.  Later I could reference the track data and be warned when I’m approaching them then next time through.  At any rate, the ability to use the technology on a compact mobile system is possible.

Summary – watch the watch

In this topic we covered the concepts of computer vision.  I did an introduction to OpenCV as well as SimpleCV and some key differences.  I then went through the procedures to installing SimpleCV on the RPi.  From there we ran through a couple of examples to show that our install worked.  Finally, I covered some applications of computer vision technology.

This has been a basic introduction to the topic of computer vision.  From here we can take the next step toward machine automation based on visual input from advanced sensor devices.

There were a host of examples that I would like to list here.

Comments are closed.