Mathias Dietz Weblog

4. November 2010

Images with GPS tags - Nautilus integration 2/2

Abgelegt unter: General, Linux — admin @ 00:55

The following two scripts are helpful for integrating the gpsPlacename.sh into nautilus:

nautilus-gps-link.sh will show the GPS position of the selected image in Google Maps.
If multiple images are selected, the first 10 GPS positions will be displayed in a static Google Map (did not find out how to display multiple markers in a dynamic map)
Zenity is used for displaying a progress bar, so please make sure to have zenity installed as well.
WARNING: wordpress adds additional single quotes (””””””””) to each single quote when saving this article, please replace duplicate ”” with a single instance
#!/bin/bash
if [ $# == 1 ] ; then
gpsPlaceName.sh -vv “$@” | tee /tmp/gpsPlaOutxxx.txt | zenity –progress –pulsate –auto-close ; cat /tmp/gpsPlaOutxxx.txt | grep dynamicmap | cut -d ””””””””””””””””””””””””””””””””>”””””””””””””””””””””””””””””””” -f 2- | xargs -n 1 -x -d ””””””””””””””””””””””””””””””””n”””””””””””””””””””””””””””””””” firefox
else
gpsPlaceName.sh -vv “$@” | tee /tmp/gpsPlaOutxxx.txt | zenity –progress –pulsate –auto-close ; cat /tmp/gpsPlaOutxxx.txt | grep staticmap | cut -d ””””””””””””””””””””””””””””””””>”””””””””””””””””””””””””””””””” -f 2- | xargs -n 1 -d ””””””””””””””””””””””””””””””””n”””””””””””””””””””””””””””””””” firefox
fi

nautilus-gps-place.sh will show the nearest place to the GPS positions of the selected image in a dialog using zenity.
#!/bin/bash
gpsPlaceName.sh -v "$@" | tee /tmp/gpsPlaOutxxx.txt | zenity --progress --pulsate --auto-close ; zenity --text-info --filename=/tmp/gpsPlaOutxxx.txt --width 800 --height 800 ; rm /tmp/gpsPlaOutxxx.txt

Example Dialog:
gps

To integrate this into Nautilus you should install nautilus-actions, then run nautilus-action-config-tool to add new entries:
nautilusaction

Images with GPS tags - Nautilus integration 1/2

Abgelegt unter: General, Linux — Tags: — admin @ 00:30

I just bought a new Sony Camera with build-in GPS. Unfortunately all the packaged software is for Windows only.
So I was looking for a good Linux program to quickly show the GPS data of a picture and to show the GPS position in Google maps.
Digikam has a good GPS support (integration of marble) and its good to manage many images.
You can even choose multiple images and show them on the map, or select a region on the map to search for pictures.

screenshot-digikam

But if you just want to show the GPS postition of a single image quickly, digikam is to heavyweight.
Many small tools can show the exif metadata of a picture, but the plain GPS coordinates are not very helpful to find out where a picture has been taken.

For this reason I have created a set of small scripts which do the following
1) Extract the GPS coordinates and get the name of the nearest place/city/village (thanks to geonames.org)
2) Open the GPS coordinates in Google Maps
3) Show the GPS coordinates of up to 10 pictures in a Google static map

The main script (gpsPlacenames.sh) provides the core functions and can be used on the shell.
The two helper scripts (nautilus-gps-link.sh, nautilus-gps-place.sh) are used for integrating it into nautilus and providing X window dialogs using zentity.

gpsPlacenames.sh
WARNING: wordpress adds additional single quotes (”) to each single quote when saving this article, please replace duplicate ”””” with a single instance
#!/bin/sh
#
# Script for extracting GPS tags from jpeg images and showing the names of the nearest place/city.
# Added some funtions to print out Google maps URLs
# author blog@dietzm.de
#
verbose=0
if [ "$1" == "-v" ];then
echo verbose enabled
verbose=1
shift
fi
if [ "$1" == "-vv" ];then
echo verbose with google maps link enabled
verbose=2
shift
fi
if [ -z "$1" ] ; then
echo Wrong usage !
echo This script extracts the GPS coordinates from exif tags of a jpeg image and shows the name of the nearest place/city/village
echo Usage: $0 [-v verbose | -vv verbose with google maps link] file….
echo —-
exit 1
fi
staticurl=”http://maps.google.com/maps/api/staticmap?size=640×640&sensor=false&maptype=hybrid”
dynurl=”http://maps.google.de/maps”
cache=/tmp/gpscache/
mkdir $cache &>/dev/null
nr=0
IFS=$””n””
echo # Reading file metadata …..
allcoord=`exiftool -q -fast -c %.6f -p ””lat=$gps:GPSLatitude&lng=$gps:GPSLongitude $gps:GPSLatitudeRef $gps:GPSLongitudeRef $directory/$filename”” “$@” 2>&1`
echo # Looking up place names (thanks to http://ws.geonames.org/)
echo ————————
for coord in $allcoord ;
do
#echo “# $coord”
# coord=`exiftool -c %.6f -p ””lat=$gps:GPSLatitude&lng=$gps:GPSLongitude $gps:GPSLatitudeRef $gps:GPSLongitudeRef”” “$i” 2>/dev/null`
hasgpsdata=`echo $coord | grep -v “Warning”`
if [ -z "$hasgpsdata" ]; then
# #zenity –error –text “exiftool command failed: $i ($?)”
fname=`echo $coord | cut -d ”” ”” -f 8-`
echo # “$fname -> NO GPS DATA”
continue
fi
i=`echo $coord | cut -d ”” ”” -f 4- | sed s#^./##g`
# echo $coord
ref=`echo $coord | cut -d ”” ”” -f 2`
if [ "$ref" != "North" ];then
coord=`echo $coord | sed s/lat=/lat=-/g`
fi
ref=`echo $coord | cut -d ”” ”” -f 3`
if [ "$ref" != "East" ];then
coord=`echo $coord | sed s/lng=/lng=-/g`
fi
coord=`echo $coord | cut -d ”” ”” -f 1`
cfile=`echo $cache$coord | sed s/&//g`
if [ -f $cfile ];then
used_cache=”C”
else
used_cache=”"
# echo wget http://ws.geonames.org/findNearbyPlaceName –post-data “$coord” –output-document=gpsname.txt
wget http://ws.geonames.org/findNearbyPlaceName –post-data “$coord” –output-document=”$cfile” &> /dev/null
fi
#Print out data
if [ "$verbose" != "0" ];then
cat $cfile | cut -d ””>”” -f 2 | cut -d ””<'''' -f 1 | xargs echo # "$i $used_cache-> ”
if [ "$verbose" == "2" ];then
mapscoord=`echo $coord | sed s/&lng=/,/g | sed s/lat=//g`
echo ” Google Maps link (dynamicmap) -> $dynurl?q=$mapscoord%28$i%29″
if [ $nr -lt 10 ];then
#limit number of marker points to 10
staticurl=$staticurl”&markers=color%3Ablue%7Clabel%3A$nr%7C$mapscoord”
let nr=$nr+1
fi
fi
else
cat $cfile |grep toponymName | cut -d ””>”” -f 2 | cut -d ””<'''' -f 1 | xargs echo # "$i ->”
fi
done
if [ "$verbose" == "2" -a "$nr" -ne "0" ];then
echo ————————
echo Static Google Maps URL with the first 10 images as markers:
echo “Link -> $staticurl”
fi
echo # Done

For the command line version (gpsPlacenames.sh) you just need exiftool (and standard tools like wget,grep,cut,..)
gpsPlacenames.sh, here we go:
#> gpsPlacenames.sh DSC018*
# Reading file metadata .....
# Looking up place names (thanks to http://ws.geonames.org/)
------------------------
# DSC01839.JPG -> NO GPS DATA
# DSC01840.JPG -> NO GPS DATA
# DSC01813.JPG -> Zeppelinheim
# DSC01814.JPG -> Zeppelinheim
# DSC01815.JPG -> Zeppelinheim
# DSC01825.JPG -> Pozo Negro
# DSC01831.JPG -> Pozo Negro
# DSC01835.JPG -> Pozo Negro
# DSC01836.JPG -> Pozo Negro
# DSC01843.JPG -> Costa Calma

gpsPlacenames.sh -v verbose will display additional information
#> gpsPlacenames.sh -v DSC018*
verbose enabled
# Reading file metadata .....
# Looking up place names (thanks to http://ws.geonames.org/)
------------------------
# DSC01838.JPG -> NO GPS DATA
# DSC01839.JPG -> NO GPS DATA
# DSC01840.JPG -> NO GPS DATA
# DSC01813.JPG C-> Zeppelinheim Zeppelinheim 50.03333 8.61667 2804754 DE Germany P PPL 2.53043
# DSC01814.JPG C-> Zeppelinheim Zeppelinheim 50.03333 8.61667 2804754 DE Germany P PPL 2.53043
# DSC01815.JPG C-> Zeppelinheim Zeppelinheim 50.03333 8.61667 2804754 DE Germany P PPL 2.53043
# DSC01825.JPG C-> Pozo Negro Pozo Negro 28.31667 -13.88333 2512315 ES Spain P PPL 6.06183
# DSC01831.JPG C-> Pozo Negro Pozo Negro 28.31667 -13.88333 2512315 ES Spain P PPL 6.06183
# DSC01833.JPG C-> Pozo Negro Pozo Negro 28.31667 -13.88333 2512315 ES Spain P PPL 6.06183
# DSC01841.JPG C-> Costa Calma Costa Calma 28.16155 -14.22691 6544327 ES Spain P PPL 0.20955

gpsPlacenames.sh -vv verbose with Google maps support will display additional information and links Google maps.
It will print out a link to the dynamic Google maps version for each image and a combined link with the first 10 images to a static google map at the end.
#> gpsPlacenames.sh -vv DSC018*
verbose with google maps link enabled
# Reading file metadata .....
# Looking up place names (thanks to http://ws.geonames.org/)
------------------------
# DSC01807.JPG -> NO GPS DATA
# DSC01840.JPG -> NO GPS DATA
# DSC01813.JPG C-> Zeppelinheim Zeppelinheim 50.03333 8.61667 2804754 DE Germany P PPL 2.53043
Google Maps link (dynamicmap) -> http://maps.google.de/maps?q=50.049895,8.592363%28DSC01813.JPG%29
# DSC01814.JPG C-> Zeppelinheim Zeppelinheim 50.03333 8.61667 2804754 DE Germany P PPL 2.53043
Google Maps link (dynamicmap) -> http://maps.google.de/maps?q=50.049895,8.592363%28DSC01814.JPG%29
# DSC01825.JPG C-> Pozo Negro Pozo Negro 28.31667 -13.88333 2512315 ES Spain P PPL 6.06183
Google Maps link (dynamicmap) -> http://maps.google.de/maps?q=28.322073,-13.944958%28DSC01825.JPG%29
# DSC01826.JPG C-> Pozo Negro Pozo Negro 28.31667 -13.88333 2512315 ES Spain P PPL 6.06183
------------------------
Static Google Maps URL with the first 10 images as markers:
Link -> http://maps.google.com/maps/api/staticmap?size=640x640&sensor=false&maptype=hybrid&markers=color%3Ablue%7Clabel%3A0%7C50.049895,8.592363&markers=color%3Ablue%7Clabel%3A1%7C50.049895,8.592363&markers=color%3Ablue%7Clabel%3A2%7C50.049895,8.592363&markers=color%3Ablue%7Clabel%3A3%7C50.049895,8.592363&markers=color%3Ablue%7Clabel%3A4%7C50.049895,8.592363&markers=color%3Ablue%7Clabel%3A5%7C28.322073,-13.944958&markers=color%3Ablue%7Clabel%3A6%7C28.322073,-13.944958&markers=color%3Ablue%7Clabel%3A7%7C28.322073,-13.944958&markers=color%3Ablue%7Clabel%3A8%7C28.322073,-13.944958&markers=color%3Ablue%7Clabel%3A9%7C28.322073,-13.944958
# Done

Now, you can easily get the GPS place names for all you images on the command line and use the printed links to jump directly to the GPS coordinates in google maps .
Cool huuh ?

7. Dezember 2009

Nokia 5800 - Wer kennt wen - Widget

Abgelegt unter: Nokia 5800 — Tags:, , — admin @ 02:13

Ich habe heute ein Wer kennt wen Widget für mein Nokia 5800 MusikXpress gebaut.
wkw

Es ruft einfach die mobile Version der WKW Webseite auf (http://mobil.wer-kennt-wen.de/)

Download: Wer-kennt-wen Widget (wkw.wgz)

11. Februar 2007

Migrated my nanoblogger based weblog to WordPress

Abgelegt unter: General, Nanoblogger — admin @ 23:32

I’ve migrated my nanoblogger based weblog to the Strato Weblog Basic which is based on WordPress

The migration was very error prone, because Wordpress adds a “br” after each line. Also Strato does not
allow to use a custom theme and the build-in theme has only a width of 800px.

So, the most blog entries are readable but not very nice. The Nanoblogger page was ways nicer.
Here a short summary:
Strato Weblog Basic (WordPress) Advantages / Disadvantages
++allows users to comment a blog entry
+easy management via web sites
+easy upload of files
–The default theme is limited to 800px width
–Strato doesn’t allow a custom theme
-The management via web sites is slow

MDGrab- New version with Authentication

Abgelegt unter: Webcam — admin @ 13:32

Ive create a new version of the commandline videograbber tool MDGrab. (see downloads)
New Features:
-send keep alive packets
-authentication added
-webcam control added (up,left,right,down,nightshot)
-some fixes

It required the following jars which you can find here: http://jakarta.apache.org/commons/
-commons-logging
-commons-httpclient
-commons-codecs

Example command to view live video on linux:

java -cp
commons-httpclient-3.0.1.jar:commons-logging.jar:commons-codec-1.3.jar:MDGrab.jar
de.dietzm.webcam.MDGrab 192.168.0.55 - admin adminpw | mplayer - -demuxer mpeg4es -msglevel all=1

A detailed description will follow.

Ovislink Airlive system access

Abgelegt unter: Webcam — admin @ 12:52

The Ovislink Airlive WL-5460CAM has a security hole which allows you to access the buildin Linux system, read and modify
configuration files.
How ?
-Open the web interface of the webcam
-Choose configuration
-Store/backup your configuration into a file
-Open this file with a text editor
-Search the section with the /sbin/ifconfig …. line, this section is the backup of your /etc/rc.d/rc.sysinit
-Everything you write into this section will be executed on startup (but be careful that it does not block/hang)
-For Example: Add a new line “ls -l /etc >> /etc/hosts” this will list all files in /etc and print the result in /etc/hosts
-Now restore your modified configuration file and reboot the webcam.
Why print to /etc/hosts ?

Because it is the next section in you backup configuration, after reboot you can read the result in your configuration backup.

Try it out ! If your Webcam doesn’t start anymore, you can reset it to the factory defaults.
With some effort it should also be possible to install a telnet or ssh binary to get remote access
Please keep me informed If you managed to get remote access.

Here is the process list of my webcam:

  PID  Uid     VmSize Stat Command
    1 root        316 S   init
    2 root            SW  [keventd]
    3 root            SWN [ksoftirqd_CPU0]
    4 root            SW  [kswapd]
    5 root            SW  [bdflush]
    6 root            SW  [kupdated]
    8 root            SW  [mtdblockd]
    9 root            SW  [ftld]
   10 root            SW  [khubd]
   13 root        312 S   init
   14 root        396 S   /bin/sh /etc/rc.d/rc.sysinit
   36 root            SW< [loop0]
  156 root        208 S   /usr/sbin/chkbutton
  158 root        220 S   /bin/op_server 0 0 0
  183 root        584 D   go-server
  184 root        416 S   ipv_server
  186 root        388 S   /bin/sh /etc/rc.d/rc.init.sh
  188 root        416 S   ipv_server
  189 root        416 S   ipv_server
  196 root        288 R   /bin/ps x

19. November 2006

Ovislink 5460 Webcam video grabber tool (MDGrab)

Abgelegt unter: Webcam — admin @ 19:51

I’ve finished the first version of a java based video grabber tool.
It grabs the live stream of the ovislink webcam and stores it into a file.
MDGrab Java Package (JRE 1.5.x required)

To start the video grabber command line tool, enter the following command:
java -jar MDGrab.jar [webcam IP-Address] [output filename]

18. November 2006

Cellvision Header

Abgelegt unter: Webcam — admin @ 03:43

To get the plain mpeg4 video stream I had to remove Cellvisions additional header structure.
The header seems to be always 40 bytes long, and index 24-27 are the size of the following video data.
In java it look like this:

byte[] hdr = new byte[HEADERSIZE];
int r = in.read(hdr);
//convert 4 bytes to an int
int ret = (hdr[27]& 0xFF)<< 24 | (hdr[26]& 0xFF) << 16 | (hdr[25]& 0xFF) << 8 | (hdr[24]& 0xFF);


I’ll provide a sample program later (check downloads).

WebCam Network Stream analysed

Abgelegt unter: Webcam — admin @ 03:27

After some hours of network tracing. I found out how the Webcam works:

It has multiple TCP Ports open:

Port 80 = Web Interface. All commands to control the webcam (pan&tilt…) are http requests.It also handles the authentication
Port 5000 = Stream initialization.
Port 5001 = Streaming Port, sends the video packets
Port 500 = documented as ipview port. But ipview pro does not connect to this port !
dynamic Port = UPnp Mediaserver port

The following sequence is used to start the video streaming:
1) connect to port 80 and authenticate (http authentication)
2) connect to port 5000, send a init sequence and disconnect
3) connect to port 5001, send a start sequence and receive the video stream (with a cellvision header in each packet)

Ovislink Airlive = Cellvision CAS670W

Abgelegt unter: Webcam — admin @ 03:01

Meanwhile I found out that the Ovislink Airlive 5460CAM is equal to the Cellvision CAS670W.

Cellvision seems to be the original developer of the Webcam, while tracing the network traffic I found a lot
of “Cellvision” strings in the package header.
Cellvision offers a Aragorn SDK which is a documentation of a webcam protocol (but not 100% equals).

Ältere Artikel »

Powered by WordPress ( WordPress Deutschland )