Saturday, 28 March 2009

Acer Crystal Eye image capture

Intro
I have been idly attempting to get a utility to grab a frame from my laptop webcam (an Acer Crystal Eye).

Whilst the webcam works fine with the likes of Cheese, the act of perfoming an automated grab with the likes of CamE was unsuccessful. There is, I believe a problem with CamE, Ubuntu, the web cam and V4l2 working in harmony.

After trawling through the repositories, I finally found fswebcam which worked a treat.

Installingsudo apt-get install fswebcam
Configuring


In your home directory, create a file .fswc.confinput 0
top-banner
title "Prawn Cam"
timestamp "%d-%m-%Y %H:%M:%S (%Z)"
font /usr/share/fonts/truetype/freefont/FreeMono.ttf

Running

To demonstrate the flexibility of fswebcam, I generated a shell script to save a time-stamped file and copy the time-stamped file to another machine using scp.#!/bin/sh

TARGET_DIR="$HOME/.webcam"
OFFSITE_DIR="remote.server.name:/path/to/.webcam"
CONFIG_FILE="$HOME/.fswc.conf"

EXT="jpg"
FILE_TIME=`date +%H%M%S`
FILE_NAME=$FILE_TIME.$EXT

if [ ! -d $TARGET_DIR ]; then

mkdir $TARGET_DIR

fi

cd $TARGET_DIR

fswebcam -c $CONFIG_FILE --save $FILE_NAME
scp $FILE_NAME $OFFSITE_DIR/$FILE_NAME


That's it. Setup crontab to run the task as frequently as you wish.crontab -e

*/1 * * * * /usr/local/bin/webcap.sh
Will run the task every minute. (A little extreme, perhaps).

No comments: