The idea is to add an event to Google calendar with some short start time from now (say 15 minutes) and SMS reminder feature.
#!/bin/bash # reminder via google with 15 minutes from now start time # MESSAGE="Neptune ALARM: something nasty has happened!" # In case of service failure try 3 times: for i in 1 2 3; do # Compute 15min from now time with date: NOW=`date "+%s"` TIME_SHF1=$(($NOW + 900 )) FWD_TIME1=`date +"%d/%m/%Y %H:%M" -d"@$TIME_SHF1"`; # Check for optional script argument if [ -n "$1" ] ; then MESSAGE="Neptune ALARM: $1" ; fi # use GoogleCL to add to calendar with 15m from now/1m reminder google calendar add "$MESSAGE $FWD_TIME1" --reminder="1m" RC=$? if [ $RC -ne 0 ] ; then sleep 30; else break ; fi done
The script uses GoogleCL (a python-based command-line utility for accessing Google). Installing GoogleCL is easy:
sudo apt-get install googlecl # or (in case there is no ready-to install package): wget http://googlecl.googlecode.com/files/googlecl-0.9.13.tar.gz tar -zxvf googlecl-0.9.13.tar.gz cd googlecl-0.9.13 sudo python setup.py install
Note: googleCL is launched via
The first time one uses googleCL, ie:
google calendar add "test from neptune 22/03/2013 10:30:22"
it will prompt for one's Google username. One has to type it in and hit enter. Next the user is asked to grant access permissions.
On non-gui systems (text-based) w3m browser usually will be launched.
When connected to google one has to press
and the text silimlar to the following will be displayed:
Please log in and/or grant access via your browser at https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=\ 4%xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&hd=default then hit enter.
One has to copy the above link to another machine (with gui browser).
Next one has to grant access and then go back to the terminal
enter to complete the authorization.
BTW the access token is stored in:
If access is granted from some machine it will probably suffice to copy the access token file to another machine to grant access for it as well (not tested).
The configuration file for googleCL is in:
If access is grated successfully the message similar to the following will be displayed:
Event created: http://www.google.com/calendar/event?eid=anFsdGFucXFwdmZnbW1sMmcwc2t1NDI3cm8gbG9vc2VoZWFkcHJvcDFAbQ
I would like to remote control a still camera via
After consulting a list of supported cameras I bought (used) Canon A620
from Allegro (local Internet auction site, sort of E-bay).
This camera has many great features (I suspect even too great as Canon stop producing cheap cameras of this sort):
viewfinder, retractable LCD and can be powered with Compact Power Adapter CA-PS500 instead of batteries
(an important feature in my project).
The plan was simple: connect camera via USB cable to computer and power it with PSU. Capture photos periodically with
gphoto2 --auto-detect pi@raspberrystar ~/bin $ gphoto2 --auto-detect Model Port ---------------------------------------------------------- Canon PowerShot A620 (PTP mode) usb:001,006
So far, so good.
Now, I tried to capture a photo:
# one shot without flash, download the file and store in a file named as: GPHyyyymmddhhmm.jpg LANG=C gphoto2 --set-config flashmode=0 --capture-image-and-download --filename "GPH%Y%m%d%H%M.jpg"
As the creation time is wrong (due to camera wrong clock) I modified
the above as follows (note that
touch is used to adjust file's timestamp):
#!/bin/basg FILENAME="GPH`date +"%Y%m%d%H%M"`.jpg" LANG=C gphoto2 --set-config flashmode=0 --capture-image-and-download --filename "$FILENAME" touch "$FILENAME"
Unfortunately there are problems: I am able to remotely capture only one photo. Next remote capture try results in an error and the camera has to be hard reset (with power on/off button). The problem is reported by others too.
BTW: when I connected the camera to my PC the reliability is much better (but seems not perfect---I experienced camera disconnection too.)
My first try to resolve the problems was to update
(raspbian contains version 2.4.14 of
## optionally remove old version (there are no dependencies) apt-get remove gphoto2
There is no need to remove
gphoto2 as compiled one
will be installed in another directory (
First install/compile the necessary packages:
apt-get install -y libltdl-dev libusb-dev libexif-dev libpopt-dev ## Download and install newer version of libusb 1.0.11 wget http://ftp.de.debian.org/debian/pool/main/libu/libusbx/libusbx_1.0.11.orig.tar.bz2 tar xjvf libusbx_1.0.11.orig.tar.bz2 cd libusbx-1.0.11/ ./configure && make && sudo make install ## Download and install newer version of libgphoto wget http://garr.dl.sourceforge.net/project/gphoto/libgphoto/184.108.40.206/libgphoto2-220.127.116.11.tar.bz2 tar xjf libgphoto2-2.5.0.tar.bz2 cd libgphoto2-18.104.22.168 ./configure && make && sudo make install
Download and install newer version of gphoto2
wget http://downloads.sourceforge.net/project/gphoto/gphoto/2.5.1/gphoto2-2.5.1.tar.gz tar xzvf gphoto2-2.5.1.tar.gz cd gphoto2-2.5.1 ./configure && make && sudo make install ## run ldconfig sudo ldconfig gphoto2 --version gphoto2 2.5.1 Copyright (c) 2000-2013 Lutz Mueller i inni
gphoto2 on my fedora 14 box requires
#configure: error: cannot compile and link against libltdl #libgphoto2 requires libltdl (the libtool dl* library), #but cannot compile and link against it. yum -y install libtool-ltdl-devel popt-devel
Upon installing above two packages, the compilation of
Unfortunately installing new version of
gphoto2 did not help.
The problem will be further examined...
Some time ago I bought a Contour HD camera on Ebay and the seller claimed he was selling it as he want to upgrade to GPS enabled model. That inspired me to investigate how I can do the same with the camera lacking build-in GPS receiver. For example to geotag photos one can use GPS enabled still cameras, but usually it is a costly luxury and it suffice to synchronize GPS log with a photo timestamp. Using this approach I have developed a simple bash scripts which works neatly with all my cameras. So I can geotag my photographs without wasting a lot of time.
In case of video images the approach is similar: one has to synchronize video and GPS data. The best approach is to film the display of the GPS unit showing the GPS time. In case when the camera is unable to get a good quality image (because the digits are too small for example as in case of my Garmin Legend) a simple trick can be used: just one has to write down time on a sheet of paper (using 15-30 seconds time-ahead) and in a appropriate moment film it. Or one can says out loudly the time displayed if the microphone is able to record it. Looks silly and old fashioned but works. Instead of the above two methods one have to establish initial video geolocation with `visual correlation' method (described in the next paragraph).
The camera Pause button should not be used as it breaks out the GPS-camera synchronization. Namely after every pause one has to establish correct initial geolocation which can be difficult but not impossible (`visual correlation' can be used ie. inspecting video for distinguishable objects which geo-position can be established). I think the advantage of GPS-equipped camcorder boils down to that aspect (one can use Pause w/o worrying that his/her video will be out of sync.) but I suspect to take this extra advantage some extra software is needed which almost for sure runs on MS Windows. For a Linux users it can be usless or at least troublesome.
The only method I tried to augment video files with GPS data is to convert them to video subtitles. Since version 1.4 of GPSBabel is able to create a subtitle file from a GPS tracklog. The subtitle contains latitude/longitude/altitude as well as the time and current speed.
To convert GPX file to subtitles one have to execute:
gpsbabel -i gpx -f FILE.gpx -o subrip,video_time=hhmmss,gps_time=hhmmss,gps_date=YYYYMMDD -F FILE.srt
video position (relative to beginning of video) for which exact corresponding GPS timestamp
gps_time -- the time part
of the GPS timestamp which corresponds to a known position in the video.
gps_date -- the date part of
the GPS timestamp which corresponds to a known position in the video.
Let's assume that the recorded image of GPS display appears in 15 second of the captured image.
One has to look for (inside GPX file) the timestamp containing
the exact time displayed (element <time> inside element <trkpt>).
this timestamp is
To convert GPX to subtitles one has to run:
gpsbabel -i gpx -f FILE.gpx -o subrip,video_time=000015,gps_time=095829,gps_date=20130207 -F FILE.srt
Just to remind: internally all GPS units record time/date using Coordinated Universal Time aka Greenwich Mean Time vel Zulu time (for army enthusiasts). What the unit displays is another matter (usually it displays local time).
My first geotagged video obtained using method described above can be seen here.
Added 21 April 2013: This post is (partially) obsolete as I prefer `visual correlation' method now (see my newer post.)