
For the longest time I have had the idea to build an Internet controllable telerobotic camera and do it WITHOUT using some cheap USB web cam and not brake the bank all at the same time. Slowly the components somehow fell into my lap so here is what came out:
Capabilities: the camera can move up and down, left and right and the user can control its lights if the lighting is not sufficient. Based on one's bandwidth, the FPS can be as high as the CPU of the server can encode. All programming is the fruits of my retarded cgi-bin Perl skill. As you guessed this is based on Linux platform and Apache for the cgi-bin part
So the basic components of the project include:
| Component | Function in the project | What I paid for it | Where I got this part from |
| CMOS composite video color camera | This is the camera - center piece of the project | $35 from eBay - camera shipped from Hong Kong | eBay - look for any composite output camera, note this is NOT a USB camera |
| Pan and tilt motorized gearbox camera stand - 110V AC | This is the mechanical Pan - Tilt mechanism that moves the cam | $59 directly from Synetlink in 2004 | http://www.synetlink.com/product/product.php?active=product&no=41&uid=37 |
| Composite video capture card WinTV | Capture card for cam video | $35 from eBay in 2004 | www.hauppauge.com |
| FFmpeg real time video server encoder | Real time video encoder server | FREE | http://sourceforge.net/projects/ffmpeg/ |
| Parallel port relay board- Kit 74 | Interface for driving Pan Tilt unit | $39 or something like that | http://www.kitsrus.com/kits.html#k74 |
| Ikea picture frame lights | Halogen lights with adapter | $19 for each light | http://www.ikea.com/ms/en_US/index.html |
| Red Hat 9 - last free edition of RedHat | Platform OS and Apache web server - all built-in for free | FREE | www.redhat.com |
Hardware
The first step was to assemble the kit74 board and test it. It comes with a nice c++ control program called k74 which is used to control the relays, and also read their status. The only sticking point was that I needed a male 25DB to male 25DB parallel cable. I had an old Umax parallel port scanner that happened to come with just the right cable so I used it If you don't have that kind of cable you will have to make one. The board comes with DB25 female connector so one can see why a regular printer cable will not do. You will need 12V power adapter to power the board, any 7V+ DC adapter will do and the board comes with a jack so you can just plug-in the adapter. If not a terminal block is also available to connect power.

Next was the task of wiring the Pan Tilt unit with the relay board. The Pan Tilt is 110V powered so one must be careful with insulation and making a custom cable for the motor unit. It conveniently comes with one spare proprietary 8 pin connector and a manual describing which pin drives what motor and in which direction:

The cable comes out nicely if you use the supplied spare connector which mates with the pigtail that comes out of the Pan Tilt drive:

Once the wiring is finished you should be able to control the Pan Tilt unit with the k74 program. For example if you want to make the camera rotate just issue the command 'k74 set 0' and your camera will start rotating until the limit switch on the Pan Tilt gearbox stops it. Ahhh yes will have to compile k74.c and your wiring should be such that bit 0 is connected to the horizontal rotation motor. Of course you can wire the unit any way you like. I just happened to wire but 0 that way in my setup. One last finishing touch for the wiring is to hook up your lights. I used 2 Ikea picture lights so that the user can turn them ON and OFF if the lighting is too low for a fun experience. Both lights go into the same relay. As k74 has 8 of them you are just fine connecting even more lights or whatever...
One last note about the gearbox operation - I was surprised to see that the
interface provides separate wires for each direction which means one could
mechanically damage the mechanism. For example applying voltage on up and down
concurrently will do something bad to the mechanics. So to avoid this situation
I wired the direction control using 4 relays in such a way that it is not
possible to send self destructive command to the Pan Tilt mechanism. Here is the
wiring schematic. Relays 1 and 3 control the voltage of the desired command and
relays 2 and 4 select the command itself. So for example to turn the camera up
you would rise the bit for relay 1 and 2. To turn down you only raise the bit
for relay 1 as relay 2 NC (normally closed) contacts by default will make the
unit turn down: 
Software
Now it comes time to figure out the software. WinTV is automatically recognized by RedHat 9 and a driver module is loaded- it comes with RedHat. Next -- FFmpeg is a pretty complicated package so you will have to figure out the compile and install steps. Sourceforge is a great place and I had no problem downloading, compiling and configuring FFmpeg to pipe 30 frames per second 640x480 video. Of course it only works inside the house LAN at that resolution. I used WinTV card from eBay which is a PCI video capture card. You can use most any card that works with FFmpeg, I hear even a cheap USB cam will do eliminating the need for composite camera and capture card. However I am yet to see a USB cam that can compete with good old analog composite video.
Once you have FFmpeg running you should be bale to hit your Linux box using Windows Media Player or WinAmp with URL such as http://192.168.1.10:8090/test1.asf and if you configured it correctly you should see a slightly delayed real time video. Ahh yes you have to connect your composite camera to the composite input of the WinTV card and setup the card to capture from its composite input rather than the built-in TV tuner.
Lastly is the control part - I used bunch of cgi-bin scripts to move left, right, up and down and to turn the lights on and off. Here is an example of down.pl:
#!/usr/bin/perl
print "Content-type: text/html\r\n\r\n";
print "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">";
print "Camera is now moving down 10 degrees, please wait\r\n\r\n";
$ENV{PATH} = '/bin:/usr/bin:/usr/local/sbin:/usr/local/bin';
system '/usr/local/bin/k74 7 set';
system 'sleep 5';
system '/usr/local/bin/k74 7 clear';
print "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=http:/camera.html\">\r\n";
The call to system is required since k74 needs to run as root in order to write
to the IO port. This is all - write your own scripts and timing as you wish.
Here are some pictures of the finished project: