#!/bin/bash
######################################################################
# Copyright (C) 2004.  Kurt Schwehr
# Released under the GPL
#
# Small script to periodically grab frames from an iSight
# http://www.mulle-kybernetik.com/software/MulleSight/
#
# NOTE: this version is completely lacking in any error checking!
# 
######################################################################


# First make sure MulleSight is running
open /Applications/MulleSight-1.0.9/MulleSight.app

sleep 2

declare -i fileNum=$3

result=0
echo "Starting..."
while [ "0" == $result ]; do 
    echo $fileNum
    fileName=`printf "%05d.png" $fileNum`
    osascript /Applications/MulleSight-1.0.9/MulleSightAsWebcam.applescript
    echo convert /tmp/picture.tiff  $fileName
    convert /tmp/picture.tiff  $fileName
    fileNum=$[fileNum+1]
    sleep 2
done

