This page contains scripts, links to other sites and "howto" docs that the staff at Open Technologies Inc. commonly use. You are free to use this material as you wish, but we take NO responsibility for your proper or improper use of this material. See Limitation of Liability below. ------------------------------------------------------------------------------------------------------------- #!/bin/sh #---Description: webcamcollage.sh (aka farmcamcollage.sh) is a shell script to automatically move # and capture images from the Trendnet TV-IP400W Wireless internet camera. # This script was written to run on Solaris, but could easily be modified to run elsewhere. # Solaris 10 comes with wget and the ImageMagick tools to create the final collage. # This script uses "wget" to position the camera (CGI post) and wget to capture the image. # ImageMagick is used to create a collage from the captured images. The only added # package needed, is the "mpack" tool to create the mime encoded email attachments. # Future versions will include options to create a panoramic view of the captured images. # #--Created by: Phillip Fiedler, 04-28-09, Version 0.3 (Tag: Innovate. Do something. Just make it happen.) # #--Parameters: Need to specify the location of this script (sdir) # Need to specify the list of camera "pre-set" positions from which the images will be captured # Need to specify (if emailing) the email address to send the collage # Need to specify the camera URL # Need to specify the camera port number # Need to specify the username to access the camera # Need to specify the password for the user to access the camera # Need to specify the preset position to return camera to after capturing images # Need to specify the X by Y size of the collages (e.g., 2x6) #---Set script directory sdir="/opt/scripts" #---Specify list of "preset" images to get (example below show preset positions separated by "\n") imagelist="22\n23\n2\n14\n6\n21\n4\n20\n" finalposition=4 #---Email Address emailaddress=myemail@domain.com #---Camera URL cameraURL=host.mydomain.com #---Camera Port Number cameraPort=80 #---Camera Username and password to access the camera (to move and capture) camuser=myusername campass=mypassword #---Collage Size collagesize=2x4 #------------------------------------------- #---Sometimes needed to wake up camera ...? Just grab an image and throw it away. /usr/sfw/bin/wget http://$cameraURL:$cameraPort/IMAGE.JPG \ --quiet --http-user=$camuser --http-passwd=$campass if [ -f $sdir/IMAGE.JPG ]; then rm $sdir/IMAGE.JPG fi #---For each preset position given, go to position, wait 15 seconds and then grab the image for i in `printf $imagelist`; do /usr/sfw/bin/wget --post-data=PanTiltPresetPositionMove=$i \ http://$cameraURL:$cameraPort/PANTILTCONTROL.CGI \ -O /dev/null --quiet --http-user=$camuser --http-passwd=$campass sleep 15 /usr/sfw/bin/wget http://$cameraURL:$cameraPort/IMAGE.JPG \ --quiet --http-user=$camuser --http-passwd=$campass #---If the image was grabbed, rename/move to sub-folder image if [ -f $sdir/IMAGE.JPG ]; then mv $sdir/IMAGE.JPG $sdir/images/IMAGE-$i.JPG fi imageFiles="$imageFiles $sdir/images/IMAGE-$i.JPG" done #---Build Collage cFile="FarmCamCollage-`date '+%m%d%y-%H%M'`.jpg" firstimage=`echo $imageFiles | awk '{print $1}'` if [ -f $firstimage ]; then /usr/sfw/bin/montage $imageFiles -mode Concatenate -size 640 -geometry 640 -frame 4 \ -quality 90 -sharpen 15 -tile $collagesize $sdir/images/$cFile fi #---Email collage sleep 10 cd $sdir/images /usr/local/bin/mpack -s $cFile $cFile $emailaddress #---Return camera to preferred position /usr/sfw/bin/wget --post-data=PanTiltPresetPositionMove=$finalposition \ http://$cameraURL:$cameraPort/PANTILTCONTROL.CGI \ -O /dev/null --quiet --http-user=$camuser --http-passwd=$campass #---Remove/Cleanup temporary image files if [ -f $cFile ]; then rm $sdir/images/$cFile fi for i in `printf $imagelist`; do if [ -f $sdir/images/IMAGE-$i.JPG ]; then rm $sdir/images/IMAGE-$i.JPG fi done exit 0 -------------------------------------------------------------------- LIMITATION OF LIABILITY TO THE FULL EXTENT PERMITTED BY LAW, HOST IS NOT LIABLE TO YOU OR ANY OTHER INDIVIDUAL OR ENTITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL OR CONSEQUENTIAL DAMAGES RELATED TO OR ARISING OUT OF ANY USE OF, ACCESS TO, OR INABILITY TO ACCESS THIS WEBSITE, CONTENT, SERVICES, OR OF ANY OTHER LINKED WEBSITE OR EXTERNAL RESOURCE INCLUDING, WITHOUT LIMITATION, ANY LOST PROFITS, LOST SALES, LOST REVENUE, LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA EVEN IF OPEN TECHNOLOGIES INC. IS EXPRESSLY ADVISED OR AWARE OF THE POSSIBILITY OF SUCH DAMAGES OR LOSSES. YOU ASSUME ALL RISK FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR LOSS OF DATA THAT RESULTS FROM OBTAINING ANY CONTENT FROM THE WEBSITE, INCLUDING ANY DAMAGES RESULTING FROM COMPUTER VIRUSES, WORMS, OR OTHER ITEMS OF A DESTRUCTIVE NATURE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU.