Windows DevCenter    
 Published on Windows DevCenter (http://www.windowsdevcenter.com/)
 See this if you're having trouble printing code examples


Using Your Webcam for Surveillance

by Wei-Meng Lee
09/06/2005

Webcams are useful for videoconferencing, but videoconferencing has not really caught on. So if you own a webcam, you know that most of the time it is lying around gathering dust. But if you have a webcam, you can put it to better use than videoconferencing. In this article, I will show you how you can set up your webcam as a surveillance system using the appropriate hardware and software.

The Hardware

Obviously the first piece of hardware you need is a webcam. Webcams come in all shapes and sizes, so you need to choose one that fits your specific security needs. If you want to use your webcam to monitor activities on your front porch, or in your antiques room, you might want to get one that is small (see Figure 1) so that it can be hidden from sight. You may also need to get an USB extension for your webcam (most webcams today use USB for communication) so that it can be connected to your PC if it is situated at a distant location.

Note that the maximum length of an USB cable is five meters and for anything beyond that you need to have an active-repeater cable. Check out your local cable shops for the length of cable you need and ensure that your webcam works in that range. For more information about USB limitations, check out this FAQ.

Figure 1. Hardware needed
Figure 1. Hardware needed

The Software--webcamXP

Once your webcam is properly set up and connected, you need a good piece of software that can turn your webcam into a monitoring agent. For this, the webcamXP Pro is a very good candidate. For this article, I downloaded the webcamXP Pro Trial v2.16.568x BETA--a 21-day trial edition. After the trial period you can purchase the license for $99.95 .

When webcamXP launches for the first time, it will help you to set up your computer for broadcasting over the internet (see Figure 2). This step is necessary for those of you installing webcamXP behind a router and who want to view your webcam through the internet. In a typical setup, your computer may be connected to the Internet using a router, which uses NAT (Network Address Translation) to assign local IP addresses to computers in the network. When you're on the internet and want to access the webcam behind a router, you need to configure your router for IP forwarding. Refer to this help page for instructions on how to configure some of the most common routers in the market.

Figure 2. Configuring webcamXP for internet access
Figure 2. Configuring webcamXP for internet access

The main windows of webcamXP are shown in Figure 3. You can monitor up to 10 webcams, represented by the squares numbered from 1 to 10.

Figure 3. The main windows of webcamXP
Figure 3. The main windows of webcamXP

Windows XP Unwired

Related Reading

Windows XP Unwired
A Guide for Home, Office, and the Road
By Wei-Meng Lee

For this article, I will use two webcams. To add the first webcam, right-click on the square numbered 1 and then select connect --> directx video sources. Select the first webcam. In my case my first webcam is "logitech quickcam web." (See Figure 4.)

Figure 4. Adding a webcam
Figure 4. Adding a webcam

To add an additional webcam, repeat the above steps by selecting the square numbered 2. I can now monitor the two webcams by simply clicking on either one of them (see Figure 5).

Figure 5. Monitoring two webcams
Figure 5. Monitoring two webcams

You can drag the various webcams out of the squares and then position them onto the desktop (see Figure 6). You can even change their sizes. This allows me to view the webcams while I am working on my computer.

Figure 6. Monitoring the webcams on the desktop
Figure 6. Monitoring the webcams on the desktop

Besides viewing the webcams live, you can also record the footage captured by the webcams as movies, as well as take pictures. By default they are saved in the C:\Program Files\webcamXP folder (see Figure 7).

Figure 7. Recording and capturing footage from the webcams
Figure 7. Recording and capturing footage from the webcams

Detecting Motions

One of the coolest features in webcamXP is its motion detection ability. You can configure webcamXP to detect motions and then raise an alert. For example, you might want to monitor activities in your house when you are out for work in the daytime. You can configure webcamXP to detect suspicious movements and take snapshots from the webcams, or record the footage as movies (a few more options are available; see the motion detection tab in Figure 8). You can also configure webcamXP to automatically send an alert email to you with the snapshot taken. Most interestingly, you can set the percentage change in motion so that minor changes in the areas being monitored won't trigger an alert (such as minor movements caused by winds, etc).

Figure 8. Configuring for motion detection
Figure 8. Configuring for motion detection

While motion detection is cool, make sure that you have sufficient disk space because this option eats up hard disk spaces rather quickly (especially if you enable movie taking) and is CPU intensive. Figure 9 shows the snapshots taken by the motion detection feature. I have set the motion detection to trigger an alert when the motion changes by 20 percent.

Figure 9. Snapshots taken by the motion detection feature
Figure 9. Snapshots taken by the motion detection feature

Remote Monitoring

webcamXP supports remote monitoring of webcams via web pages. By default, an internal web server will automatically be started to allow your webcams to be viewed remotely. In the Users Manager tab, you can configure the security of webcamXP. Obviously, you do not want just anyone to view your webcams, so be sure to check the "watch is password protected" and "protect each request" checkboxes (see Figure 10). You can authorize additional users by clicking on the Edit Users... button. You can also grant/deny accesses based on IP addresses.

Figure 10. Securing webcamXP
Figure 10. Securing webcamXP

You can configure the internal web server by clicking on the web/broadcast tab. Note the port number used by the web server (8080 in this case; see Figure 11).

Figure 11. Configuring the web broadcast
Figure 11. Configuring the web broadcast

Once secured, authorized users can view the webcams using the IP address that you configured earlier for IP forwarding. If you are viewing the pages within your local network, you can use the IP address of the computer together with the port number, such as http://10.0.1.2:8080 (see Figure 12).

Figure 12. Viewing the webcams using a web browser
Figure 12. Viewing the webcams using a web browser

Wei-Meng Lee (Microsoft MVP) http://weimenglee.blogspot.com is a technologist and founder of Developer Learning Solutions http://www.developerlearningsolutions.com, a technology company specializing in hands-on training on the latest Microsoft technologies.


Return to the Windows DevCenter.

Copyright © 2009 O'Reilly Media, Inc.