iSight Webcam Setup for OSX

Posted by ljmacphee on February 6, 2007 under how to, osx, tools, webcam | 5 Comments to Read

{most recent webcam shot}

To run an iSight webcam first make a directory off your home directory. Call it webcam or something like that.

I downloaded isightcapture from Intergalactic. This free, but not open source, program will grab a picture from your iSight. Put this program in your new webcam directory.

To ftp the pictures up to your website you need to create a perl program ‘webcam.pl’
This perl program takes and uploads a picture every 300 seconds ( 5 minutes ) change the number of seconds to suit you.

#loop forever or until program terminated
while (){

$takepicture = “./isightcapture snapshot.jpg”;
print $takepicture.”\n”;
if ( system($takepicture)) { print “failed to take picture\n”; }

$uploadpicture = “ftp < upload”;
print $uploadpicture.”\n”;
if ( system($uploadpicture)) { print “failed to upload picture\n”; }

sleep(300);

}

Now make that file executable at a command prompt type
>chmod 755 webcam.pl

Next create a .netrc file in your home directory substituting yourwebsite.com, yourloginame and yourpassword. Be sure permissions are set to 600 ( chmod 600 .netrc ).

machine yourwebsite.com
login yourloginname
password yourpassword

{this is highly insecure, your password is in plain text so use this at your own risk!}

Finally create the upload file. snapshot.jpg is the name of the picture that isightcapture takes. Change yourwebsite.com and yourwebcamdirectory to be the name of your website and the directory on your website you are uploading your snapshots into.

open yourwebsite.com
prompt
binary
cd yourwebcamdirectory
put snapshot.jpg
bye

Once all this is done and everything is in the same directory except .netrc open a new terminal window, cd to your webcam directory. Type ./webcam.pl and you’re taking and uploading pictures. You will see the output from isightcapture and the ftp program. So any problems should be clear to you and easy to fix.

Now in your webpage just put in a link to the picture to have the current picture appear in a webpage.

*All these sample files can be downloaded osxwebcam.tar.gz

Webcam set up under linux

Posted by ljmacphee on February 3, 2007 under how to, linux, tools, webcam | Be the First to Comment

{most recent webcam shot}

Ok, the webcam is backup and running. The setup is a bit different now.

For those using newer 2.4.5+ kernels the driver is built in, but you have to recompile your kernel. You will also want to download the pwcx driver from the Philips camera driver page.

If you are running an older kernel in which the webcam driver is not built in, pre 2.4.5 then you need to download the driver from the Philips camera driver page. and install it. He gives excellent step by step instructions for doing so.

For the older kernels I used Camserv at Source Forge. It compiled and ran totally painlessly.

If you are using a newer kernel 2.4.5+ then recompile your kernel with the built in philips camera driver. Be sure to turn on usb, the camera, input core support and event interface support. You will need to download and add in the pwcx kernel from the Philips camera driver page. He gives excellent instructions for doing so.

I downloaded his camstream program (also on the philips driver page) but vjgrabber works just as well. Use either of these programs to grab the pictures and write them to a file. I made a webcam directory off my home directory and stuck everything in there.

To ftp the pictures up to your website you need to add a routine to your .bashrc file, write an upload script and add or create an entry in the .netrc file. Instuctions for each follow:

The .netrc file belongs in your home directory. Be sure permissions are set to 600. If you don’t have one already just create a file with these three lines substituting yourwebsite.com, yourloginname, and yourpassword.

machine yourwebsite.com
login yourloginname
password yourpassword

Add this to your .bashrc file

upload is the name of the script that does the uploading, you can name it whatever you like and just change the name here. Sleep is the number of seconds between uploads. Set this to what ever you like.

function webcam()
{

export LOOP=”true”
while [ $LOOP = "true" ]; do
ftp < upload
sleep 300
done

}

This is the upload file. Snapshot.jpg is the name of the picture that camstream takes.

open yourwebsite.com
prompt
binary
cd yourwebcamdirectory
put snapshot.jpg
bye

I put the snapshot.jpg and upload in a webcam directory.
Once you done all of this, open a new shell so .bashrc will run again.
Start the program that is taking the pictures and have them saved
in this directory as snapshot.jpg. I just overwrite the previous
one.

In the webpage I put the following 2 lines after the heading and before the body, this seems to work refreshing the page.

< /head>
< META HTTP-EQUIV=”refresh” content=”300″>
< META HTTP-EQUIV=”Pragma” content=”no-cache”>
< body>