Pages

Sunday, May 22, 2011

Linux Webcam

I was trying to get a webcam pointed at my driveway working under Ubuntu Linux, mostly because we have been having snowfalls as recently as last weekend, so it is useful when I leave work to know what to expect.  The program webcam works, but like most things Linux, and most things free, it is slightly harder to set up than the equivalent for Windows.

Anyway, the webcam is here (although I do not have the page set up to automatically reload).  To run the webcam program, you need to set up the .webcamrc file, and then nohup webcam .webcamrc, which starts it running.  The .webcamrc file was actually a bit more obscure than I expected it to be.  Here I have gone thorough and marked up the lines from the default settings that needed changing.

[grab]
device = /dev/video0
text = "webcam %Y-%m-%d %H:%M:%S"
#infofile = filename
Apparently, the infofile parameter is used for local storage; having it set just made error messages.
fg_red = 255
fg_green = 255
fg_blue = 255
width = 640
height = 480
delay = 600
wait = 0
input = Camera 1
 cameratype is found by executing v4lctl show input at the command line.  Note that there are no quotes around the cameratype, even though it includes a blank in the name.
#norm = pal
My first assumption was that I needed to set this to NTSC, the television standard in North America.  But no, it turned out that this line needed to be commented out, instead.
rotate = 0
top = 0
left = 0
bottom = -1
right = -1
quality = 75
trigger = 0
once = 0

[ftp]
host = claytoncramer.com
I could not get ftp working to upload the picture to my web page, so I decided to use ssh instead.  In this case, you only specify the domain name--not ftp.claytoncramer.com, which is what you would need to use ftp instead.
user = USERID
pass = PASSWORD
Obviously, you fill in your user ID and password here.  I could not get the ssh key stuff working (which would have eliminated the need for the password parameter), but this does not worry me.
dir  = public_html/
file = webcam.jpg
#tmp  = uploading.jpg
Not quite sure what the tmp parameter does, but commenting it out made this work.
passive = 1
Probably only needed for ftp, but I was not sure.  At least, it does no harm with ssh.
debug = 3
Sets the level of debugging information displayed; I should probably set this back to 0.
auto = 1
Causes automatic updating of the picture through either ftp or ssh.
local = 0
Only set to a non-zero value if this is running on the server for the webcam page, so that you do not need to transfer the image to another computer.
ssh = 1
Tells webcam to use ssh instead of ftp.

Run it in background with nohup webcam .webcamrc&

I should probably make it run automatically at startup, but it is late, and I want to get back reading this book about the Tudors.

The obscure fields are "input = cameratype" where cameratype http://www.claytoncramer.com/webcam.html is found by executing v4lctl show input at the command line.

Also obscure was the norm = pal field--just comment it out with a # at the start of the line.

In the

1 comment:

  1. Just browsing by and saw the title of this post.

    You should try out motion, here:

    http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome

    It has lots of nice features, most particularly for your use, I think, the feature that it can detect motion.

    VERY good for static scenes, where you want to detect intrusion, etc.

    Not so good if you get dogs, cats, skunks, racoons and deer crossing your drive, although it is incredibly easy to have the pics directed to a file. (Video or pictures).

    I have played with it using a D-Link internet webcam. Absolutely great! Just browse to the IP address and view.
    Geoff

    ReplyDelete