Auto-captioning photos with CAPTCHAner

Sunday, January 13th, 2008

I quite often have completley unachievable ideas, that have no basis whatsoever in fact or reality. So, it’s no surprise that a conversation with Craig, down the pub on Friday has sparked another of them.

It’s become a bit of a theme this year, and after my last posts on the subject – we got to talking about captioning photos. Many of my photos exist on the basis of seeing something shiny, and then taking a picture. I often have no idea what said shiny thing was – but quite often make the effort usually on Google, or Rough Guides to discover its secrets afterwards.

I encourage any account holders to tag as many photos as they want on Blakepics. But mine is a very small community, and Flickr shadows it with even its tiniest fingernail. So, why should you have to tag your own photos? Aren’t there plenty of other people out there that would do that for you?

And I got thinking about the recaptcha project. They use scans of words to present the user with captchas that will help their digitization of old texts. These “unknowns” are combined with”known” text, and the answers compared against previous users results.

So, why not the same for photos? A known photo could be presented to the user “Dog”, “Cat”, “Llama”, or even a traditional captcha. Combine that with an unknown photo, and invite users to give it a caption. According to recaptcha, there are 60 million captchas being solved every day – it’s about time we put all that to good use.

Or perhaps CAPTCHA might just become another word for blackmail. Sure, you can login to your account – but you have to do something for me first. I just like the way Captchaner, sounds (Captcha, Captioner – see what I did there?). Maybe one day we’ll see this on all of our logins.

Mobile Blakepics with Gallery2, AddViaEmail, Gmail, Symbian and Shozu

Wednesday, September 12th, 2007

12092007013.jpg
The plan was to get photos on Blakepics without the hassle of using computers, web browsers, memory card readers, cables, wires or Royal Mail. The secondary goal of the whole thing is to be a bit cool – so naturally it’s a mash-up of a number of different partially connected services, and I’ll briefly mention Facebook just so that we can check that one off and call it Web 2.0.

So, first step – Gallery2 has an AddViaEmail module. Install that, signup for a Google Mail account and get yourself a really obscure email address. Once you’ve got the AddViaEmail installed and configured (yep, it supports Google’s SSL pop3 servers), you can send emails to that address and have them automagically added to a specific album on your Gallery2 server.

You could stop here if you like – most mobile phones come with email software nowadays. So you can write an email, attach your images, and off they go. But I find email on the little keypads really annoying. And there’s all that typing, clicking, and making sure you get things right to worry about. You’re not exactly cutting edge, with email … are you? Besides, we’ve only made use of three different vaguely related services. That’s not what the web of the future is all about. I’ve heard about it in fairy tales.

So, get yourself a Shozu account. They provide a really cool backup / Share-It service and comes complete with a Symbian application which you can install on your brand new ultra-shiny Nokia N95. For example. If you use this, you can get yourself some single-click access to uploading your photos. Actually, it’s a 3-click minimum. But it’s better than typing email addresses or searching for contacts. They provide a bunch of other ways of sharing your photos, such as uploading to the BBC for consideration as part of their stories. Or more usefully to a WordPress blog or Facebook to humiliate your mates before they’ve got home from the pub and had a chance to de-tag all your new compromising photos.

But alas, AddViaEmail and Shozu don’t play very nicely. So, here are some changes to make to your php script (don’t be scared, it won’t bite).

/modules/addviaemail/classes/AddViaEmailHelper.class – Fix problems with the mime type…
list ($ret, $item) = GalleryCoreApi::addItemToAlbum($pathToSaveFile . $filename,$filename, $filename, $summary, '', $mimeType, $targetDestination);
->
list ($ret, $item) = GalleryCoreApi::addItemToAlbum($pathToSaveFile . $filename,$filename, $filename, $summary, '', 'image/jpeg', $targetDestination);
You’ll also need to disable the subject line spam checker as Shozu will send your email with the subject line as the name of the image.

So just remove this:

$header_info->subject == $subjectToMatch &&

The spam checker is actually quite a cool function, so one of these days I’ll come back an regular expression that. But quite likely, I probably won’t post it here. So work it out for yourself :)

See, and that’s all there is to it. I can now upload loads of photos direct through my phone (as I did with the image at the top of the page), and you could too.

Hacking the Facebook Developer API

Sunday, June 3rd, 2007

It’s been a while since I’ve written very much code just for myself, rather than everyone else. So this weekend I’ve decided to jump onto the Facebook API and learn a little bit more about the Gallery2 API in the process.

Why?

I have thousands of photos on Blakepics, and Facebook comes along and wants me to upload them all over again. Well, sure, I can do that – or, it makes a lot more sense to combine the power of the two systems.

What?

Wanting to keep this initial trial run extremely simple – I’ve gone for just adding a link below my profile picture. That way I can keep very clear of the Gallery API for the time being effectively reducing my problems by half :)

How?

  1. User adds the Blakepics application on Facebook
  2. Setting the Callback URL on Facebook, a request is made to Blakepics.com
  3. Blakepics.com makes use of the Facebook API to check the currently logged in user
    // the facebook client library
    include_once('../modules/facebooktaggedalbums/api/client/facebook.php');
    include_once('../modules/facebooktaggedalbums/api/client/facebookapi_php5_restlib.php');
    // some basic library functions
    include_once('../modules/facebooktaggedalbums/api/lib.php');
    // this defines some of your basic setup
    include_once('../modules/facebooktaggedalbums/api/config.php');
    $facebook = new Facebook($api_key, $secret);
    $facebook->require_frame();
    $user = $facebook->require_login();
  4. Using this user ID, Blakepics requests the first and last name of that user from Facebook
    $user_info = $facebook->api_client->users_getInfo ($user, 'first_name,last_name');
  5. Generate a URL that links to the tagged album, e.g. http://www.blakepics.com/key/kevin+blake. Using the rather cool FBML (FaceBook Markup Language), the link can be sent to Facebook with the instruction that this should be applied as a profile action (fb:profile-action).
    $fbml="<fb:profile-action url=\"http://www.blakepics.com/key/" . $user_info[0]['first_name'] . "+".$user_info[0]['last_name']."\">View more Photos of me at Blakepics</fb:profile-action>";
    $facebook->api_client->profile_setFBML($fbml, $user);
  6. And display a message back to the user, to let them know what’s happened
    print "Blakepics profile link has been added";

And that’s it really. Obviously there’s a lot more that can be done, but the simple application works and is on its way to approval from the Facebook team. All being well, you should be able to add your own links to tagged albums very shortly.

Gallery Tagging and Web X.0

Saturday, March 17th, 2007

Flickr’s had some really quite cool tagging facilities for quite some time now. In this day and age, it’s not enough to put something on the web. Anyone with AOL Website Builder can do that (and sadly, they do). The Semantic Web is all the rage now. You need to be embrace it if you’re going to be part of the the hip crowd of Web 2.0. Or is that for Web 3.0? I forget.

We’ve always had keywords, the meta content for your pages to help search engines out in finding your content. But that just doesn’t cut it any more. Nowadays you have be tagged or labelled, dynamic, geographically aware, mash-up your own content with a multitude of other sites, bleed ajax from your eyeballs, stay mobile, accessible, interactive, and generally ensure that no two-visits to your site are ever exactly the same. If you’re not achieving that quite frankly – you’re terribly 1.0, and I’m afraid – nobody.

So imagine my excitement when I heard the news that Gallery the leviathan behind Blakepics was going to be making more use of the beloved photo keywords, not just for search – but in a Flick-esque, semantic, ever-evolving keyword extravaganza. If this was excitement, then I was feeling it. After a long wait, and drooling over alphas, betas and release candidates – the dream has been made a reality, and the wait is finally over.

So, I now have the ability to supplement my standard albums with dynamic ones. Photos of Christmas in London can now be a part of both the Christmas and London “albums”. Dynamic albums showing off all the llamas, no matter where I saw them, or holidays, europe, america, mobile phone pictures. This has also introduced the keyword “cloud” at the bottom of every page, which not only gives a way of seeing the albums, but which keywords are the most popular.

It’s not the only addition / improvement of course – but it’s one I’ve been looking forward to for a very long time :)

Geo-tagging the universe, one step at a time…

Sunday, October 1st, 2006

I’ve recently brought myself a Track Stick, after Ben pointed them out on thinkgeek.com. Believe it or not, the purpose of this purchase was not to attach it to the underside of a family members car, nor will I be attempting to covertly attach it to employees feet to verify that they’re are just going across the river for some lunch and not in actual fact going for an interview somewhere else.

In fact, it’s far less sinister than all of that, to track my holidays, places I’ve been, and more importantly – the photos I take whilst I’m there. Geotagging, or geocoding has received quite a lot of press lately, since Flickr have introduced it into their service.

I took the Track Stick into London at the weekend, for a trial run before Croatia later this month. The concept is quite simple. The GPS device records your co-ordinates alongside the time and date. The camera records the time and date when you took the photo. Once you’re back home on your PC, you can use these two pieces of information to automatically add co-ordinates into each of your photos’ EXIF headers (metadata). From there, it gets really fun :)

  • View your photos on a map like Google Earth.
  • Search for your photos based on location.
  • Find other photos that were taken in a similar area.
  • Automatically create descriptions of your photos based on how other people describe theirs of the same place.
  • Use all of those photos to construct 3D models of your holiday.

Okay, the technology isn’t all there, yet. But the important thing is to start gathering this data and to certainly make what use of it you can. So, that’s what I’ve done :)

How to tag your photos

  1. You’re going to need a GPX track file, like the one here. The bare minimum you need is the latitude, longitude and date/time. Sadly, my Track Stick won’t output this by default. So I had to create a small script to make one from the CSV format it does supply. If you’re in a similar position, you can download my quick hacked together perl script to create your own. I may improve on this in the future, but for now it works.
  2. Secondly, I used a small application called WMMX Location Stamper.
  3. Click on Photos -> Add Photos, and select all the photos you want to tag.
  4. Click on Tracks -> Add Tracks…, and load the file you’ve created as above (or obtained elsewhere if you’re not using a Track Stick).
  5. Click the Apply Tracks button on the bottom, and you’re done – geotagged photos.

Viewing your photos in Google Earth

Using Picasa2, you can save your photos in a Google Earth file and share your entire journey with your friends and family.

  1. Just load your photos into Picasa2 (File -> Add folder to Picasa)
  2. Select the photos you have just added
  3. Click Tools -> GeoTag -> Export to Google Earth
  4. Select a location, where you want to save your file.

Gallery2 / Blakepics

Finally, all of these photos can tie into Gallery2 (which is what I’ll be doing) using the existing Google Maps Module, or watch this space on Tadek’s blog, for a really promising looking module to view locations on single images.

Useful Resources

I came across a number of other useful little applications out there, which while weren’t directly useful to me – might be very helpful to you, so here they are :)

  • WMMX Location Stamper – Stamp your photos with GPS information. Totally Free.
  • Google Earth – The best way to view your photos afterwards ;)
  • Grazer - Another GPS stamping application
  • GPS Visualizer – A great online tool to sort our your GPX files, and much more.
  • Photo Studio – John Hawkins’ explanation of geotagging with Photo Studio.
  • GPS Babel – Converts your GPS track files between loads of different formats (though wouldn’t play nicely with the track stick – let me know if you have more luck!)
  • Robo Geo – nice tagging tool, but it’s a pay-for software and doesn’t really do the job any better than the rest of them.