By Mike Keesling
Optics
For Your Robot
Using A Webcam
It is said that the eyes are the window to the soul. This leads one to
wonder if we give a man-made machine our visual capability, would
we then imbue our mechanical constructs with a soul? Well, I am no
philosopher or spiritual statesman upon his ziggurat, but I can tell you
that with a little understanding of light and optics, you can introduce
a lot of capability into your robotic projects.
Machine vision is a very tricky subject
with a lot of variables to understand. To
the uninitiated, it is hard to know where
to begin a project at all beyond buying a
camera and a lens, and hoping things
work out. To help demonstrate some
concepts, I will detail some aspects of a
project we are doing for fun here at the
office. We are converting an old
typewriter to “tweet” messages that are
typed into it. Rather than building switch
closures on every key, we thought it might
be fun to use machine vision as a
solution.
Before we dig too deeply into the
project, there are a lot of different things
to think about. I’ll cover the very basics of
cameras, lenses, and imaging ideas that
one may encounter in most any machine
vision or optical sensing project.
38 SERVO 01.2010
Light and Color
Light, as many of us know, is just another
form of electromagnetic radiation. We perceive
light in the wavelength range of 400 nm to 700
nm as the color range from violet to red. We do
this biologically, deriving color from cones and
resolution from rods in our eyes. We have color
sensors that are red, green, and blue, and when
we build digital devices, we generally try to make
the bulk of them behave as an analogue of our
own sight.
Most of today’s digital cameras use red,
green, and blue colored pixels (actually photosites)
in a predictable arrangement called a Bayer
pattern, with alternating rows being RGRGRGRG
and GBGBGBGB, and so forth. Four photosites
(two per row) are grouped together to form a
colored pixel. Shift over one column, take another
four as before, and you have your next pixel.
You will notice two things. One is that there