Thursday, February 9, 2012

How Webcams Work



by Marshall Brain
If you have been exploring the Web for any length of time, then you have run across any number of Webcams in your travels. Webcams range from the silly to the serious -- a Webcam might point at a coffee pot or a space shuttle launch pad. There are business cams, personal cams, private cams, traffic cams... you name it and there's probably a Webcam pointed at it!
Have you ever considered setting up a Webcam yourself? You might want to create a silly cam by pointing it at your hamster or putting it inside your refrigerator. But it turns out there are lots of productive uses for Webcams, too. For example:
• You will be out of town for a week and you want to keep an eye on your house plants.
• You'd like to be able to check on the baby sitter and make sure everything is okay while you are at work.
• You'd like to know what your dog does in the back yard all day long.
• You want to let the grandparents watch the new baby during nap time.
If there is something that you would like to monitor remotely, a Webcam makes it easy!
In this article, we will look at the steps you can take to put up your own simple Web camera.
The Basic Idea Webcams, like most things, range from simple to complex. Let's start with simple.
A simple Webcam consists of a digital camera attached to your computer. Cameras like these have dropped well below $100 and they are easy to connect through a USB port (earlier cameras connected through a dedicated card or the parallel port). A piece of software connects to the camera and grabs a frame from it periodically. For example, the software might grab a still image from the camera once every 30 seconds. The software then turns that image into a normal JPG file and uploads it to your Web server. The JPG image can be placed on any Web page (for information on creating Web pages and adding JPG images, see How Web Pages Work).
If you don't have a Web server, several companies (like the makers of Webcam32) now offer you a free place to upload your images, saving you the trouble of having to set up and maintain a Web server or a hosted Web site.
This is the simplest possible Webcam. Putting a standard JPG image into a standard Web page is straightforward, but it has the disadvantage that your readers must manually refresh the image. Using a meta tag, a JavaScript function or a Java applet, it is possible to create a system that automatically refreshes the image for your readers.
What You Need In order for you to create a simple Webcam, you need three things:
1. A camera of some sort connected to your computer
2. A piece of software that can grab a frame from the camera periodically
3. A Web server
For some people, their home computer serves as their Web server. If that's the case, these three things are all that you need. If your Web server is hosted elsewhere (for example, because you are
paying an ASP to host your Web server), you also need:
4. The ability to move frames from your computer to the Web server, normally by File Transfer Protocol (FTP), although several other protocols are gaining favor as well. For most Web servers, this is no problem; but occasionally, a hosting company will have policies in place that make this difficult.
5. A relatively consistent connection between your computer and the Internet. A modem connection to an ISP is fine if it is something that you keep connected most of the time. This implies that you have a dedicated phone line for your computer or something like a cable modem that is connected all the time.
As mentioned previously, several companies (like the makers of Webcam32, who have a feature called AutoCam) now offer you a free place to upload your images. By using one of these services, you avoid having to host and/or maintain your own Web site. If you are using one of these services, then you need:
1. A camera of some sort connected to your computer
2. A piece of software that can grab a frame from the camera periodically
3. A relatively consistent connection between your computer and the Internet.
If your connection is not consistent, it won't hurt anything. It just means that the image cannot refresh itself all the time.
Putting it All Together In order to experiment with Webcams and go through the process of setting one up, HowStuffWorks got itself a Webcam. To set it up, here is what we did:
1. We went down to the local computer warehouse and bought the Intel PC Camera Pro Pack (USB).
2. We installed the software for the camera on a Windows 98 machine. This took two tries, and we learned that it is important to turn off the virus-checking software and do a fresh reboot before installing.
3. We went to the Web site www.webcam32.com and downloaded a program called Webcam32. This is a popular software package for Webcams. Webcam32 grabs pictures from the camera and uploads them to a Web server. You can get a free demo version or pay $25 for the full version. I paid $25 for a registered copy. (The complete user's manual for this product is available on the Web site -- it offers a nice suite of features.)
4. We installed Webcam32. It was a very easy installation.
5. After entering the address of the FTP site and a couple of other pieces of information, the HowStuffWorks Webcam showed its first signs of life!
6. We pointed the camera out the window.
7. We then tuned the software a bit to reduce the file size of the images and to enable the temporary-file copying feature.
There are many different features you can experiment with in Webcam32: streaming video, chat, captions, AVI files and different resolutions and compression ratios, to name a few. Webcam32 also supports the AutoCam feature, which allows you to create a Web page for your Webcam for free on their server. The software makes it simple.
As you can see, setting up a simple Webcam is extremely easy! If nothing else, the setup described here is a fun, inexpensive and simple way to experiment with a Webcam and see what you can do
with one of your own!
Automatic Refreshing The HowStuffWorks Webcam image on this page is a static image, and readers have to refresh the image manually (by pushing the Refresh button in the browser) if they want to see any changes. There are three different techniques you can use to create automatic refreshing:
• You can add a meta tag to the HTML for the page so that the page refreshes at some frequency. The tag to add is:
<meta http-equiv="refresh" content="30">
The "30" is the number of seconds between each refresh and can be set to anything you like. The entire page will reload every 30 seconds, so it is beneficial to keep the page short.
• You can add a Java applet to your site. The Webcam32 Online Help page explains how to obtain and install the free applet. The applet is a program that automatically fetches the image periodically. The advantage is that only the image refreshes, not the entire page. Most browsers support Java applets, so most of your readers will have no problem.
• You can use JavaScript, as demonstrated on this pagefrom JavaScript.Internet.com (look at the source code on this page). You can also check out How Java Works for a detailed look at Java programming.
External Webcams One problem with using a camera hooked to a computer via a USB cable is the limited cable length. What if the room you want to capture is at the other end of the house, or outside? In that case, you need to purchase a camera like the Intel PC Camera Pro Pack (USB), which has an external video jack. You have two options when choosing an external camera:
• You can place a standard camera anywhere in the house and run a video cable with RCA jacks on it from the camera to the computer. There are all sorts of places on the Web that sell small pinhole video cameras, either on their own or embedded in things like clocks and smoke detectors. You can find small security cameras priced between $100 and $200. This page from Amazon.com shows a few of the ones you can choose from.
• You can avoid the cable by using a radio link. This page has an example.
Monitoring is only one of the things you can do with your Webcam. There are any number of ways to make use of a camera that's connected to your computer. You can even get software that will let you make video phone calls!

No comments:

Post a Comment