Montag, 15. September 2014

Hardware photos: DSLR housing, equipped with RasPi, PowerBoard and PoE splitter

The DSLR is now mounted in a waterproof housing.
Together with Raspberry Pi, selfmade PowerBoard (see earlier posts), PoE splitter.
It runs now temporarily in my backyard.
Lets see whether it runs stable and also remains dry in rainy wheather.

Now a few photos...






Freitag, 12. September 2014

install gphoto2 version 2.5.5 on raspberry pi



#/bin/sh
# Gphoto2 2.5.5 compiler and installer script v0.3.1
#
# This script is specifically created for Raspbian http://www.raspbian.org
# and Raspberry Pi http://www.raspberrypi.org but should work over any 
# Debian-based distribution
# Created and mantained by Gonzalo Cao Cabeza de Vaca
# Please send any feedback or comments to gonzalo.cao(at)gmail.com
# Updated for gPhoto2 2.5.1.1 by Peter Hinson
# Updated for gPhoto2 2.5.2 by Dmitri Popov
# Updated for gphoto2 2.5.5 by Mihai Doarna
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
if [ "$(whoami)" != "root" ]; then
echo "Sorry, this script must be executed with sudo or as root"
exit 1
fi
echo 
echo "----------------"
echo "Updating sources"
echo "----------------"
echo
apt-get update
echo 
echo "--------------------------"
echo "Removing gphoto2 if exists"
echo "--------------------------"
echo
apt-get remove -y gphoto2
echo 
echo "-----------------------"
echo "Installing dependencies"
echo "-----------------------"
echo
apt-get install -y libltdl-dev libusb-dev libexif-dev libpopt-dev libudev-dev
echo 
echo "-------------------------"
echo "Creating temporary folder"
echo "-------------------------"
echo
mkdir gphoto2-temp-folder
cd gphoto2-temp-folder
echo "gphoto2-temp-folder created"
echo 
echo "-------------------------"
echo "Downloading libusb 1.0.17"
echo "-------------------------"
echo
if wget -q http://ftp.de.debian.org/debian/pool/main/libu/libusbx/libusbx_1.0.17.orig.tar.bz2
then
tar xjvf libusbx_1.0.17.orig.tar.bz2
cd libusbx-1.0.17/
else
echo "Unable to get libusbx_1.0.17"
echo "Cleaning and exiting..."
exit 1
fi
echo 
echo "--------------------------------------"
echo "Compiling and installing libusb 1.0.17"
echo "--------------------------------------"
./configure
make
make install
cd ..
echo 
echo "----------------------------"
echo "Downloading libgphoto2 2.5.5"
echo "----------------------------"
echo
if wget -q http://downloads.sourceforge.net/project/gphoto/libgphoto/2.5.5/libgphoto2-2.5.5.tar.bz2
then
tar xjf libgphoto2-2.5.5.tar.bz2
cd libgphoto2-2.5.5
else
echo "Unable to get libgphoto2-2.5.5"
echo "Cleaning and exiting..."
exit 1
fi
echo 
echo "-----------------------------------------"
echo "Compiling and installing libgphoto2 2.5.5"
echo "-----------------------------------------"
echo
./configure
make
make install
cd ..
echo 
echo "-------------------------"
echo "Downloading gphoto2 2.5.5"
echo "-------------------------"
echo
if wget -q http://downloads.sourceforge.net/project/gphoto/gphoto/2.5.5/gphoto2-2.5.5.tar.gz
then
tar xzvf gphoto2-2.5.5.tar.gz
cd gphoto2-2.5.5
else
echo "Unable to get gphoto2-2.5.5"
echo "Cleaning and exiting..."
exit 1
fi
echo 
echo "--------------------------------"
echo "Compiling and installing gphoto2"
echo "--------------------------------" 
echo
./configure
make
make install
cd ..
echo 
echo "-----------------"
echo "Linking libraries"
echo "-----------------"  
echo
ldconfig
echo
echo "-----------------------------------------------------------------------------------------------"
echo "Setting up permissions for USB ports, see http://www.gphoto.org/doc/manual/permissions-usb.html"
echo "-----------------------------------------------------------------------------------------------"
echo
/usr/local/lib/libgphoto2/print-camera-list udev-rules version 0.98 group plugdev mode 0660 > /etc/udev/rules.d/90-libgphoto2.rules
echo 
echo "-------------------"
echo "Removing temp files"
echo "-------------------"
echo
cd ..
rm -r gphoto2-temp-folder
echo 
echo "--------------------"
echo "Finished!! Enjoy it!"
echo "--------------------"
echo
gphoto2 --version

Donnerstag, 11. September 2014

script improvements: correct naming for captured images

for the webcam gallery the images shall be tagged with a naming convetion like hhmm_xx.jpg
xx varinats are:
hu = huge (original size, for klick&zoom-view in gallery)
la = large (smaller size, for direct view in gallery)
sm = small (small size, for thumbnail view in gallery)

And the photos shall be captured each 10 minutes.
The images shall have straight minute format.

And last but not least the images shall be placed in a directory-structure like /year/month/day/

Example: the image has been shot at 15:36h. DSCF2345.jpg was downloaded form the cam, and renamed by gphoto2 to webcam.jpg.
Then by imagemagick-command 'convert' the following images will be created:
1500_hu.jpg (original)
1500_la.jpg (reduced size 50% from original)
1500_sm.jpg (reduced size 20% from original)
All 3 photos will be uploaded by FTP in the correct folder.
The date-meta-data of the original photo 'webcam.jpg' has been taken into account to create the correct directory, and place the photos correctly.

The whole shell-script with the actual improvements:


#!/bin/bash

host='HOSTNAME'
USER='USERNAME'
PASS='PASSWORD'

rm *.jpg

while true
do
/usr/bin/gphoto2 --capture-image-and-download --filename "webcam.jpg"

imgname="webcam.jpg"
year=`date --reference $imgname +%Y`
month=`date --reference $imgname +%m`
day=`date --reference $imgname +%d`
hour=`date --reference $imgname +%H`
minute=`date --reference $imgname +%M`
mom=`date --reference $imgname +%H`
min=`date --reference $imgname +%M`

# show only full 10min
let min=$min/10*10
[ "$min" = "0" ] && min="00"
mom="${mom}$min"

mv $imgname $mom"_hu".jpg
convert $mom"_hu".jpg -resize 20% $mom"_sm".jpg
convert $mom"_hu".jpg -resize 50% $mom"_la".jpg

ftp -n -v $host <<EOT
ascii
user $USER $PASS
prompt
mkdir /webcamgallerydir/$year
mkdir /webcamgallerydir/$year/$month
mkdir /webcamgallerydir/$year/$month/$day
cd /webcamgallerydir/$year/$month/$day
put $mom"_hu".jpg
put $mom"_la".jpg
put $mom"_sm".jpg
bye
EOT
rm *.jpg
echo wait 10 minutes
sleep 600
done

download file from a server using ssh

A file can be downloaded from a server remotely by using the 'scp'-command as followed:

scp username@remotehost.tld:/remotedirectory/remotefile.txt /localdirectory

Example:
> scp bart@simpson.dyndns.com:/home/homer/marge.jpg /home/bart

open ssh connection on different port

ssh connections normally get opened on port 22.
In some cases the ssh port has been changed.
To get access from by shell command on different port, use -p and the port number.

Example:

> ssh 192.168.1.150 -p 2323