Hardware Reference
In-Depth Information
Figure 9-2
Video color recognition in
Processing, using the code in
Project 22. This simple sketch
works well with vibrantly pink
monkeys.
Video Identification
All video identification relies on the same basic method:
the computer reads a camera's image and stores it as a
two-dimensional array of pixels. Each pixel has a char-
acteristic brightness and color that can be measured
using any one of a number of palettes: red-green-blue is
a common scheme for video- and screen-based applica-
tions, as is hue-saturation-value. Cyan-magenta-yellow-
black is common in print applications. The properties of
the pixels, taken as a group, form patterns of color, bright-
ness, and shape. When those patterns resemble other
patterns in the computer's memory, it can identify those
patterns as objects. Figure 9-2 shows an example, using a
bright pink monkey.
page, then follow the directions to install OpenCV on your
platform. Download the Processing OpenCV library and
copy it to the libraries directory of your Processing sketch-
book directory (find it listed in Processing's preferences).
Now you're all set to build the examples below.
NOTE: The current home of OpenCV for Processing as of this
writing is at http://ubaa.net/shared/processing/opencv . A new
version is in the works, so check the Processing site for the most
up-to-date link.
Color Recognition
Recognizing objects by color is a relatively simple process,
if you know that the color you're looking for is unique in
the camera's image. This technique is used in film and
television production to make superheroes fly. The actor
is filmed against a screen of a unique color, usually green,
which isn't a natural color for human skin. Then, the pixels
of that color are removed, and the image is combined with
a background image.
In the three projects below, you'll use a computer-vision
library called OpenCV to read an image from your personal
computer's camera or webcam, and then analyze the
image. The first, and simplest, will look for a color. The
second will look for something resembling a face. The third
will look for a 2D barcode called a QR (Quick Response)
code .
Color identification can be an effective way to track
physi-cal objects in a controlled environment. Assuming
you've got a limited number of objects in the camera's view,
and each object's color is unique and doesn't change with
the lighting conditions, you can identify each object reason-
ably well. Even slight changes in lighting can change the
color of a pixel, however, so lighting conditions need to be
tightly controlled, as the following project illustrates.
X
OpenCV is a computer-vision library originally developed
by Intel and released under an open source license. It's
been adapted for many programming environments,
including Processing. The Processing version can be found
linked off the Processing site at http://processing.org/
reference/libraries/ . Follow the OpenCV link from that
 
Search WWH ::




Custom Search