How Webcams Work
Outline:
Introduction:
Webcams come in two varieties: 1) those that connect directly to the PC and 2) those that run wirelessly. In this article I will concentrate solely on those that run wirelessly. You'll see why as you continue reading.
How they communicate:
A wireless webcam communicates using the 802.11 protocol. First, what the heck is a protocol? A "protocol" in layman's terms, is a language. In America our "protocol" is to speak English as the primary language (e.g. protocol). In Spain, they speak Spanish as their "protocol." Just in this way, wireless devices speak 802.11 as their "protocol." Using 802.11, two computer devices can communicate. One transmits and the other recieves, then they switch off. Think of it like a friendly conversation between two people - one talks while the other listens, then they switch off. Unless, of course, one person just ends up talking all the time and then....well, I digress....
Sooo...What is 802.11?
802.11 is a "protocol," or language, spoken over the airwaves at very specific frequencies.
The air-frequency band dedicated for 802.11 traffic is 2.4 GHz (gigahertz). If you
tune a transmitter designed to speak 802.11 to this frequency, and
you tune a reciever to listen on the same frequency, then those
two devices can communicate with each other. It's kind of like the radio in your car.
A radio station is transmitting at a very specific frequency, say 103.3Mhz.
Your radio in your car, if tuned to exactly 103.3Mhz, is recieving the transmissions
from the station transmitting at that frequency. In this setup, the radio interprets
the radio transmissions and produces sound from them.
Now, the case I am interested in is the one where the the wireless webcam is
acting as the transmitter, broadcasting information onto my network. On the
other end is a wireless router, picking up these transmissions from the webcam. What
happens is the router takes this radio information, interprets it using the 802.11
procotol it studied for so many years to learn, and produces TCP/IP network traffic
from it. This traffic is sent out to the internet, beaming to you from across the
planet. Sound simple enough? Ok!
Intermission:
So, we've got a webcam. And then we have a wireless router which recieves communications from that webcam. Great! Our webcam can now communicate its picturesque view to the network using it's fancy dancy protocol. Once on the network these pictures can be transmitted virtualy anywhere with the assistance of the Internet. So, how do webcams capture pictures? Read on!
How webcams capture pictures:
In simple terms, a webcam is a digital camera taking pictures over and
over and over again, one after another. These pictures get stored
in physical memory on the camera, in the built in RAM chips.
Webcams are extremely fast at taking pictures and capturing this
video data. After the camera captures the picture into memory,
it compresses it to reduce the amount of data it needs to transmit.
This happens through picture compression. One form of picture
compression you are probably already familiar with: the JPEG
picture format.
So, the camera is a taking a picture in raw format, compressing it into
a .jpg file, and then it uses it's 802.11 enabled
radio transmitter to transmit that picture over to the wireless
router. All of this is accomplished using simple digital
camera technology, compression technology, and radio communications
speaking the 802.11 protocol.
Sweet mamma! Tell me more!
How webcams stream pictures:
One way to get streaming data onto the internet is the oh-so-commonplace-nowadays
webserver.
Webserver, you say? You mean just like the one that runs
this very website? Yes, I say. Exactly the same type.
"But, wait," you say, "I thought a webserver only sent out static pages,
one at a time, and then stops?"
"How does a webpage continuously update the page to show streaming video?"
Well, dear reader, that is done through an application designed specifically
to recieve the pictures being sent from the webcam. The application "tunes
into" the webserver on the webcam. And this same application
updates the webpage in your browser, producing a live-video effect that
you see.
Here is an embedded example of what I'm talking about:
How the webcam's webserver streams video to you:
So, we have a webserver running on the webcam. The webcam, essentially, IS the webserver. This webserver can serve any type of webpage we wanted to, but it's specifically designed to serve either a) administration webpages to control and configure the webcam itself or b) streaming video. Let's concentrate on the most interesting of the two: streaming video.
Video "streams" to the browser via a Java applet that is loaded
by the browser. This applet runs within the web browser itself.
Here an example of HTML code that embeds a Java applet to stream
video to your browser:
There is one drawback here, in that the browser you use must be
able to run Java. Fortunately, all modern browsers have
this capability built into them by downloading to and by installing
Java onto the browsing machine (http://java.sun.com/javase/downloads/index.jsp).
Alrighty. Now, this java applet, running in the web browser,
requests these .jpeg pictures from the webserver (running on the
webcam, remember...?). One by one the requests are made and the
responses are sent. When the java applet recieves a response, in our
case a picture, it updates itself. Since the java applet runs within
your web browser, it appears as if the web browser is updating its
page. Well, really it is, but the java applet is helping out a LOT!
Much like a movie in the movie theatre shows you pictures one after another
very quickly, so does the java applet show you the pictures sent by the
webcam. How fast this happens is usually 15-30 times per second! Yes,
VERY fast indeed!
Summary:
In summary, we've covered:
What's next?
Let's move on to cars. Specifically, RC cars.
Click to read "How RC Cars work."