Showing posts with label geek. Show all posts
Showing posts with label geek. Show all posts

Thursday, 26 April 2012

How to make Picasa name tags be indexed by Spotlight

I recently rediscovered Picasa and am impressed with its new features - considering it is free. Thanks Google! Picasa is a photo organising and touch-up software and is available for Windows, Mac and Linux (with Wine). However, you still need to be a bit of a geek in order to not get trapped. 

What I particularly like about it is that it leaves all photos in the place I put them and does not store copies in its own folder - as iPhoto does. This makes it easier to share my photos between computers, be able to mange the photos with other software at the same time and allow me to keep the photos in a file structure that is sensible to me - namely in folders by the year in which they were taken and then in a folder for the location or trip to which they belong. Importantly, it has a small footprint on your RAM.

tagging...

What brings me to write about Picasa is its nifty naming and tagging features. Thanks to demand, if you choose so in the preferences, you can now save the names of people to the EXIF data of each JPEG. As I described in my last post, I like to be able to use my operating system to quickly search/display photos and produce slide shows based on the tags they contain. Correctly tagging all of your photos that you have accumulated over your life - if like me you have gone to the trouble of scanning them - can take an equally endless time. The Picasa facial recognition tool makes this task so much easier, if not fun. 

It sometimes comes up with amusing suggestions, particularly if it sees a face on a train or in a plate of food, but really its down side is that it does not recognise your pets and, particularly, people who are not facing the camera! It also tends to miss some people that are facing the camera. And don't bother scanning folders that have many photos with strangers in the background or you'll be up all night ignoring/hiding their faces!

When you first set Picasa up you'll be bullied into agreeing that it scans for photos in a couple of default locations. I forget if there is a way out of this, but I recommend going afterwards to Tools>Folder Manager and selecting only those folders you actually want it to manage. If you would like it to save the tagged people to the EXIF data of your photos (JPEGs only I think), go to Preferences and the Name Tags tab and select "Store name tags in photo". Note, that even if you don't select this option, if you assign any tags or comments to a photo, Picasa will anyway leave its print in the EXIF data of the photo and a unique ID number, which helps it link the photos to its database.

indexing...

Picasa stores the name tags under a tag name that is not indexed by Spotlight or, probably, the Windows indexer. Thus, it still traps you into using their software so that you are more inclined to upload your photos to share on their server. My solution to this, as before, is to duplicate the name tags to OpenMeta and Windows format tags. And here is my Bash script, that does just that, on my Mac. 


picasa2tags.sh

[edit: original code with the typo has been replaced with the following github snippet]


To use the script, copy and past it into a text editor, save it as picasa2tags.sh where you saved the other script, also make this script executable by going to the location in Terminal and entering chmod +x picasa2tags.sh and running the script as, e.g, picasa2tags.sh -r DirName

Warnings
  1. Make sure you have backed up your photos just in case something goes wrong!
  2. The script will only work properly if in my other script, om2exif.sh, you replace the exiftool option -overwrite_original  with -overwrite_original_in_place. If you don't, the new OpenMeta tags mysteriously disappear if you view them with Tagit.
  3. Unfortunately, because my om2exif.sh script does not handle spaces in tag names, this script will not either. Perhaps someone can help me sort that with a line or two of code. To enable this script to handle spaces as far as transferring the tags to OpenMeta, simply uncomment the two lines marked with "use to handle spaces"  (delete the first "#" in the line) and comment out each previous line. This apparently is not recommended by the OpenMeta help file but I think the help file is probably either inaccurate or out of date! Otherwise, in the mean time, tag names are just as search able if you enter them as AlbertEinstein or ChrisR. 
  4. Close Picasa before running script otherwise it might not recognise all of the changes you have made to the tags.

Happy Tagging!

Sunday, 15 April 2012

How do you find your favourite photos?

So, you've been won over by digital technology and, on holidays, find yourself endlessly snapping away with your camera. It does not matter how many photos you take, because it is free and you can delete the bad ones later. But what about the ones that are not bad and not that good? Ten years later you find that you have accumulated between 10 and 100 thousand photos. The few slide-shows you put together to show your mother were created with software on another computer, which you gave away when you had a brief fling with an iPad. How do you find the best photos of you and your dog? Good luck! 


Entrapment
The problem with using software to organise your photos is that it either costs money, is not available for all operating systems and most importantly you are trapped. All that work you did organising your photos is locked away in a piece of software that you might one day not like or could be discontinued or not supported on your next computer. Your photos should live longer than your computer. We need a better way. 

Tagging - its all about tagging!
In case you hadn't noticed, Windows 7 and Vista have tagging facilities built in. What you may have not known is that there are many free programs to provide this feature to other operating systems, such as Mac OS. Tagging is here to stay and one day tagging will be as standard as tabbed browsing. This is what tagging is:

Many computer files, such as photos and movies, enable one to hide written text inside them without it being normally visible. This enables one to set keywords and even descriptions and ratings to help one find them again. For example, if you went on a trip to New York you could enter the keywords "New York" and USA. On photos that contained you or your dog you can enter your names. Rating your photos might seem a faff, but if you rate the best with 5 stars and the better ones with 4 it makes setting up a slide show a doddle.

On Windows and Mac, by simply typing tag:USA Rover in the file browser search box would almost instantly bring up all the photos on your computer (or specified folder) of your dog, Rover, in the United States. On Windows, to show only the best photos, also enter something like rating:5 stars  or rating:>=4 stars, start a slide show and enjoy.

Tagging on Linux, XP and Mac
I haven't set up the use of tagging on my Linux netbook yet, but solutions exist, such as using Tracker and digiKam. I also gather that it will not be long before solutions with come bundled with the popular Linux distributions. There is TaggedFrog for Windows XP users, but again I have not used it. 

I usually use a Mac that is running Leopard and, unfortunately, I am disappointed that Apple are behind in the tagging game - probably because they want to trap their users in iPhoto, which I no longer want to use. I am not going back there. Particularly, as I like to sync my Linux netbook before I take it on an adventure. I still use it as my gps navigator!

Currently my favourite tagging software for Mac is Tagit, where one can drag selected photos to its icon in the Dock to set their tags and rattings. When the tags are set, as above, 
  • Enter something like  tag:USA Rover, in the search field in Finder. 
  • To select the best photos the command is starrating:5 or starrating:>=4  
  • To start a slide show in Leopard, select all of the photos you want to view and hit the space bar!
Sharing Tagit tagged photos with Windows users
The limitations of Tagit are that it does not support comments, one cannot easily review all of the changes one has made and it uses another method of storing the meta data than Windows that seems get lost more easily. For example, by attaching a photo directly to an email to send to another mac user the tag data is lost. To preserve tags when emailing you should zip the photos up together with the folder that they are in. I presume, because will include the hidden .DS_Store file. 

If you are happy always sticking with a Mac for now, you might be ok with only using Tagit. However, if you'd like to be able to share your tags with Windows users, the good news is that is already possible if you are prepared to learn a bit of Bash. You'll need the following command line programs
  • openmeta - to read or modify Tagit tags
  • exiftoool   - to set the EXIF data of photos
Both are free and easy to install and straight forward to use if you are familiar with using Terminal. To save you the time, I'll share my Bash script that copies Tagit tags to the EXIF data of photos so that they are also visible on Windows. Feel free to use and modify it as you like. I am no expert and can't guarantee it will do as expected so I recommend you always back up your photos before you run it. 

Novis instructions for how to use the following script:
  • You can copy/past it into a text editor and save it, perhaps in Pictures as om2exif.sh
  • Open Terminal and change directory to Pictures (or wherever you saved it) by entering the command: cd Pictures
  • Make the script executable by entering the command: chmod +x om2exif.sh
I organise my photos first by year and then by location or event. To copy all openmeta data to EXIF format for the year 2012 and recursively for all contained folders type the following command:
  • ./om2exif.sh -r 2012

Note
  1. to access the script from any location you can add it to your path, such as putting it in the folder /usr/bin/ or by specifying your own user path
  2. When I need it, or if any one requests, I shall write a similar script to copy the tags in the other direction.
  3. The title of this post was a genuin question. Please let me if you have any better (free) solutions!

om2exif - the script

#!/bin/bash

# BUGS: does not handle spaces in file names with -r and -p options
# NOTE: does not delete existing tags or rating if not set by openmeta

usage="
NAME
     om2exif -- copies openmeta tags to exif data readable by windows

SYNOPSIS
     om2exif [OPTION] [DIR/FILE]

OPTIONS 
     -r   recursively copy tags for files in directory
     -n   non recursively copy tags in direcory
     -p   path to single file to copy tags
 
"

if [ x$2 = "x" ]; then
echo "$usage"
exit
fi

if [ $1 = "-r" ] ; then 
fileList="$(find $2 -name *.[jJ][pP][gG])"
elif [ $1 = "-n" ]; then
fileList="$2/*.[jJ][pP][gG]"
elif [ $1 = "-p" ]; then
fileList=$2  #$(echo $2 | sed 's/ /\\ /g')
else
echo "$usage"
exit
fi

for file in $fileList; do
i=2
echo updating "$file"
omkeywords=$(echo $(openmeta -p "$file" | grep tags) \.) 
omrating=$(openmeta -p "$file" | grep rating | cut -d ' ' -f2 | cut -d '.' -f1) 
echo $omkeywords
echo rating: $omrating
# translate keywords
while [ $(echo $omkeywords | cut -d ' ' -f$i) != "." ]; do
newtag=$(echo $omkeywords | cut -d ' ' -f$i)
if [ $i = 2 ] ; then
subject="-subject="$newtag
lastkeywordxmp="-lastkeywordxmp="$newtag
xpkeywords=$newtag
else
subject=$subject" -subject="$newtag
lastkeywordxmp=$lastkeywordxmp" -lastkeywordxmp="$newtag
xpkeywords=$xpkeywords";"$newtag
fi
i=$(( $i + 1 ))
done
# translate rating
if [ $omrating = "none" ]; then
rating=" "
else
rating="-rating="$omrating
fi
exiftool -overwrite_original -xpkeywords=$xpkeywords $(echo $lastkeywordxmp $subject $rating) "$file"
echo "done"
echo " "
done


Useful commands
When you view the photos as described above they can be ordered by date or name. Ordering by name does not work if you have more than one type of camera. Ordering by time does not always work as the creation and modification times can/will be changed when edititing or if you scanned the photos from film etc. exiftool is useful here in that it can recursively rename your digital photos to incorporate the time and date they were taken. The following are the options I use. A comprehensive list of examples, such as for correcting creation or modification date given in exiftool's manual and online.

exiftool -r -ext JPG -d %Y.%m.%d_%H%M.%S%%-c.%%e "-filename<CreateDate" Dir/ # rename pictures

exiftool -r -ext MOV -ext AVI -d %Y.%m.%d_%H%M.%S%%-c.%%e "-filename<CreateDate" Dir/ # rename movies

NB: these are two commands spread over four lines. Replace Dir with your own directory name


Wednesday, 23 September 2009

GPS with a CVGI-B07 on Eeebuntu

Introduction

This is not part of my travel diaries, but it is part of my preparation of going to India. I know it is not the greenest thing to do, but I am planning on buying a light motorcycle to get about in India with, which in my opinion, having in the past rented a Yamaha RX 100 in Goa, is probably the most enjoyable way of travelling off the tourist trail.  Because I want to avoid the major roads, the chance of me getting lost is probably quite high. So having a GPS system for locating myself as either a last resort or to check that I haven't missed a vital turning, to me sounds like more fun than it is to be ashamed of. In rural India it can be very difficult to ask for directions because often the people are no better at helping me read my map than I am pronouncing a town's name. I probably mentioned in my previous post that I bought an eeepc so that I can jump at the possibility of performing data analysis during my volunteer experiences. So this post is both a record for myself how I set up the GPS, and particularly I hope it will be useful to anyone trawling the internet looking for the solutions to the same problems that I faced.

I still don't know when I am going to India, but it probably will be mid October now. I am still waiting to here if my corrections to my thesis are sufficient, but am about to take the risk of printing it off anyway and leaving it at uni for someone hand in for me.

Apparatus
  • Asus eeepc 1000HD - my netbook
  • Eeebuntu base 3.0 - my Linux operating system
  • CVGI-B07 USB GPS dongle (was the cheapest I could find - £22 incl. p&p from ebay)
  • GMapCatcher - allows you to download Google maps for offline viewing. Also incorporates a GPS marker.
  • python - runs GMapCatcher
  • gpsd - translates the gibberish from the dongle into coords for GMapCatcher
Method
  • Install python and gpsd. I already had python installed and I installed gpsd 2.38 through the Synaptic Package Manager.
  • Download GMapCather and unpack in a suitable place.
  • enter   tail -f /var/log/messages    into a terminal
  • Go outside if you are not already and make sure you have an unobstructed view of the sky.
  • Attach GPS dongle which will flash for some time while it locates satellites.
  • Then look at the text printed to the terminal when you plucgged in the device. Hopefully you have the PL2303 driver and it says sometime like mine: 
Sep 22 23:12:00 onyx kernel: [22297.432119] usb 2-1: new full speed USB device using uhci_hcd and address 17
Sep 22 23:12:00 onyx kernel: [22297.592456] usb 2-1: configuration #1 chosen from 1 choice

Sep 22 23:12:00 onyx kernel: [22297.597554] pl2303 2-1:1.0: pl2303 converter detected

Sep 22 23:12:00 onyx kernel: [22297.615352] usb 2-1: pl2303 converter now attached to ttyUSB0
  • Close tail with Ctrl C and enter   gpsd -bnN -D4 /dev/ttyUSB0   where the last part is taken from the port that was printed earlier - see above in red. Warning: Don't miss out the -b option for the CVGI-BO7 dongle - I'll explain below. Hopefully plenty of exciting gibberish will fly past your eyes and you might even catch a glimpse of some text saying that it has locked onto a Satellite.
  • To make more sense of all gibberish you might like to open xgps, which should have installed with gpsd. xgps will show you a graphical display of the number of locked in sats. Empty circles are not locked in. Red spots are week and green strong signals and yellow in the middle the Signal to Noise Ratio (SNR) is also listed for each satellite.
  • If you have a lock onto three or more satellites start maps.py in the GMapsCatcher folder, select Marker Centre from the GPS drop down menu that only appears when gpsd is correctly installed and running and zoom in and you should be taken to your current location. Oh, did I forget to tell you that you should have run GMapsCatcher before so that you can view the maps offline when you are outside?

Problems

Hopefully you'll have none, but if you do, here are the problems I encountered and how I solved or got around them.

- GPS does not lock onto Satellites.
  • Did you go outside? I never bothered but it does help particularly for first lock-in.
  • It seems to help to not plug the USB dongle directly into the computer but to the end of an extension USB cable.
  • I had the impression that installing/running roadnav or some navigation software once was needed to configure my CVGI-BO7 dongle as on a Windows, Mac and Linux computer it only would work once I had run such software. gpsd can't configure the dongle with the -b option set (I'll explain below). Roadnav only had a debian file for an older version of ubuntu but it still worked for me.
- You didn't listen and ran gpsd without the -b option? I wish I had been told myself! I thought I had bricked my dongle! When I sent the command the dongle light went out and when I next plugged it in the light would stay on and not flash or write anything to the serial port. It no longer could pass for Christmas decoration. The problem is that gpsd tries to optimise the device which obviously does not like it. Luckily there is a solution.
  • I found out that the CVGI-B07 GPS dongle uses a SiRF star III chip and that the company, SiRF, has a tool that you can download to configure their chips. You can download it from this link.  You want the demo tool, not the firmware. Install this on a Windoze PC and enter your dongle on the PC - after of course you have installed the PL2303 chip driver, which hopefully came with your dongle.
  • Open SiRFDemo and select your appropriate port. You can find the port number by clicking Start, right click on My Computer -> Properties, select the Hardware tab, Device Manager, expand Ports (COM & LPT) and you should see the port number there. You can remove the dongle and put it back in to make sure you have the right one.
  • Select the Baud Rate. 4800 worked for me and click the confirm button on that window. The main program should now load.
  • Click the little button that says "Connect to Data Source" when you hover your mouse over it. It should start doing stuff now.
  • Now select   |Action > Initialize Data Source. A window popped up for me at this point asking which software the chip was using. I chose the default one which was first in the list and which I found on this page but I can't remember which it was now - either GSW or GSC. On the next window I selected the option to reset and clicked send. After a few moments the dongle starting flashing again. Hurray! If you don't dare reseting it you probably can wait a week or a month or two until the internal rechargable battery runs down and the memory is cleared.
  • You can find some detailed instructions for using SiRFDemo here.
  • Using the -b option next time with gpsd prevents gpsd writing to the dongle. With the debug level set at -D2 occasionally psd complains, but it still does its job.
- Why do the markers in GMapCatcher look naf?
  • I had to hard code the path to the images  - eg replacing filename = os.path.join('images', 'marker_gps.png') with filename = os.path.join('/home/cjreeve/GMapCatcher/images', 'marker_gps.png') in the file mapGPS.py, mapMark.py, and mapPixbuf.py located in src in the GMapsCatcher directory. The problem was that the program otherwise looks for the folder images where ever you start the program and I use the Cairo Dock to start it and who knows which directory it looks in then...
  • The pin image that points to your markers (if you set any) looked too big for my liking so I scaled it down with some image editing software (The Gimp) but maintained the pixel size dimentions of the image.
Conclusion

That's pretty much it. I would currently recommend the CVGI-BO7 dongle, but this might change if it breaks as soon as I need it. I'll let you know. From my garden it locks onto 8 satellites (with SNRs between 25 and 43) in less than a minute after a days non use. It looks nice but is not branded and does not come with very helpful instructions. It comes with the Prolific 2303 Windows and Mac OS X drivers which work, but only has some old Redhat drivers for Linux. Ubuntu seems to ship with the driver so I had no problem - it just took me some time to realise. Let me know, anyone, if you found any of this information useful.






CVGI-B07 Manufacturer Specifications
  • Primary Function: GPS receiver USB dongle
  • Tracks up to 20 satellites.
  • Receiver: L1, C/A code
  • Max update rate: 1 HZ
  • Acquisition time
    • Reacquisition: 0.1 sec average
      Hot start: 1 sec.
      Warm start: 38 sec.
      Cold start: 42 sec.
  • Position Accuracy
      Non DGPS (Differential GPS)
        Position: 5-25 meter CEP without SA
        Velocity: 0.1 meters/second, without SA
        Time: 1 microsecond synchronized GPS time
      DGPS (Differential GPS)
        Position: 1 to 5 meters
        Velocity: 0.05 meters/second
      EGNOS/WAAS/Beacon
        Position
          < 2.2 meters, horizontal 95% of time
          < 5 meters vertical 95% of time
  • Dynamic Conditions:
      Altitude: 18,000 meters (60,000 feet ) max
      Velocity 515 meters (700 knots) / second max
      Acceleration: 4 G, max
      Jerk: 20 meters/second, max
  • Antenna Type: Built in Patch Antenna
  • Minimum signal tracked: -159dBm
  • Dimensions: 74 x 25 x 14 mm
  • Operating temperature: -40 to +80
  • Storage temperature: -45 to +100
  • Operating humidity: 5% to 95% No condensing.
  • Power consumption: < 80mA at 4.5- 5.5V input
  • Protocol and interface
      NMEA output protocol: V.2.2
        Baud rate: 4800 bps
        Data bit: 8
        Parity: N
        Stop bit: 1
      Interface: USB port
  • Color: Blue
  • Manufacturer Ref: ZMZP1KZL0U

Product Notes

  • **This model is compatible with most brands of GPS software - however hardware specific software such as Garmin may not run on this unit. the manufacturer provides the GPS-enabled hardware only, not the software. No warranty or customer support regarding GPS software. Any software installation you undertake should be performed or supervised by a professional.

Package Contents

  • Model CVGI-B07 GPS Receiver USB Adapter
  • CD (English user guide; drivers for Mac, Linux, and Windows operating systems; GPS testing software)
  • USB cable
  • Display/storage box