Tag Archives: iPhone

Picasso with a Fed 2

Picasso and the FED-2 (B4)

The FED-2 is a solid Soviet rangefinder camera built during the 50s and 60s. In an age of tiny digital cameras which employ magic to allow you to take thousands of perfectly exposed photos of your cat, there’s something reassuring about occasionally dipping into a past where cameras were real, mechanical objects that mere mortals could just about understand. Taking a photo of your cat was a challenging, artistic experience.

The great thing about these old cameras, and FEDs in particular, is that there are so few moving parts that almost nothing can go wrong, and as an extra insurance they built the things to last anyway.

Even better FEDs are pretty cheap. £20 or £30 on eBay should get you a reasonable FED from some bloke in Eastern Europe, where they abound. When you consider that these were pretty reasonable copies of Leica rangefinders of the period, and that these will set you back hundreds or even thousands, FEDs really do seem like great value. And you’re not buying into that whole Leica inflated-price nonsense, so you can actually take your camera out its case and use it without fear of damaging something close to a museum piece.

Below is a photo of my FED-2. It’s a B4 with a blue case. Weirdly they decided to colour their cameras in black, blue, green, and red. Don’t ask me why, because the colours are pretty dull. But I guess in the exciting world of the late 50s Soviet Union these colours must’ve seemed pretty wacky. It dates from c. 1957 and still takes good photos.

Fed 2 (no case)

OK it doesn’t have a light meter, and is totally manual. But if you want to take photos – really take photos – then what better way? A great way to learn the art of photography, certainly. Guesstimating light levels (or using the Sunny 16 rule) based on your film type, shutter speed, and aperture give you a really good feel for what you’re actually doing when you take a photo, and help you really focus on your surroundings, your subject, light quality…

Of course, you make lots of mistakes. Digital photography takes care of stuff for you much more. True, you can learn very easily on a digital camera because you can see instantly that your photo is crap. Maybe the learning process with an old manual camera is slower, but somehow more rewarding. Or am I just getting old and weird?

The name “FED”, by the way, comes from F. E. Dzerzhinsky, the man in charge of what later became the KGB. Scary stuff. And by all accounts conditions at the factory in the Ukraine where FEDs were made were not good at all. Not good at all.

But hey, we all buy cheap goods made in the sweatshops of the far east. I own an iPhone after all… So to the uber-cool liberal thinkers and artists of the pre- and post-war eras, “Soviet” often meant something more positive than we understand today. They could brush aside the small details of the crushing brutality and unfairness of the Soviet regime with the broad sweep of Ideology. It’s therefore likely that Picasso, famously interested in photography as art, made a point by owning Soviet cameras such as the FED-2.

Here’s a photo of him with a FED-2. So there you go. He owned a FED.

Picasso with a Fed 2

I’m not sure who took the photo, or when, or quite why (two watches? Making a point about something I guess…) But that’s definitely a FED-2 round his neck, despite some people on some flickr forums I’ve seen thinking it might be a Leica.

Even better, I’m pretty confident in saying it’s a FED-2 B4.

Nerdy? Well, ok. But as far as my nerdiness can tell, Picasso’s camera is identical to the one I have. And that seems a pretty cool fact to me.

The key things to look out for in a FED-2 B are:

- case with two buttons
- flash sync socket just to the side of the lens
- Industar-26M lens

You can see all these clearly in my comparison photos below.

Unfortunately identifying it as a B4 rather than any old B is trickier, because you can only tell for sure from the serial number, and the style of shutter speed dial. But I’m sure it must be a B4 because of the Industar lens.

For those of you interested in such things, I found the sovietcams.com site particularly useful for identifying Soviet cameras.

The comparison


a closeup of the fed 2 used by Picasso

His

Fed 2 (with case)

Mine

Building augmented reality layars

Layar is a free augmented reality (AR) app for iPhone and Android. Unlike other apps which fulfil a specific AR need (from finding bars near you selling Stella, to shooting your friends with lasers) Layar opens things up to let developers build their own AR views and run them in the Layar AR “browser”. It looks like the image below, which shows a wikipedia layer.

AR Browser

And yes, “browser” is kind of an apt description, because when you build a Layar layer (someone should really think of better terminology than this!) what you’re really doing is providing a webservice which gets displayed in a particular way.

Building a simple layer is actually pretty easy if you have some web development knowledge, such as PHP and MySQL. In fact, if you’re ever built a simple webservice before then all you need to build a simple layer is which parameters need to be passed in, and what the output should look like. The Layar people have provided a tutorial to help you if web development isn’t your main thing, and there’s some sample code there too. I found their wiki and tutorials useful for getting started, but in my opinion their PHP code samples are a little hacky.

Developer site

So, first you need to register as a developer. This takes just a minute. Once done, you need to start building your layer definition. This sets things like the URL of your webservice, and the name of the layer. You can also use the developer area to test your layers before submitting them for publication. Again, documentation is provided. But I found it all pretty straightforward and easy to work out anyway (they could do with some better web designers though!)

Webservice

Now the key part which makes the whole thing tick. The webservice. This can be hosted on your own site, although 3rd party sites exist, such as hoppala.eu, which in effect provide the webservice hosting for you. To be honest the hoppala service seemed great at first sight – you give it the url of a google map and it does the rest – but after various unsuccessful attempts at sending them my google map url, I gave up. Your webservice needs to provide a few key pieces of data about your layer. Basically the geo-coordinates of each point-of-interest in your layer, and a title and description for each.

Google Map

Getting geo-coordinates might sound scary, but if you’ve ever made a google map, you’ll have those to hand. If you haven’t made a google map, then it really is just an easy drag and drop exercise. There’s a little RSS button at the top right of your map where you can get the url of the RSS feed of your map. This contains all the coordinates, as well as the titles and descriptions you’ll have given when you were building up your map.

It would be cool if the Layar people would accept these RSS feeds. That way you’d not have to do anything else. To me this is the biggest oversight of the whole system. The google RSS really does contain everything they need, but hey…

OK so you just have to accept that you’re going to have to take that google map RSS feed, and modify it to put it in the format the Layar people need. In effect you’re creating a chained, 2-step, webservice. This is where your PHP and webservice skills come in.

Input data

When the Layar “browser” calls your webservice, it provides three GET parameters. The user’s current longitude, latitude, and the radius the user wants to be bothered with around them. Your webservice code therefore will need to capture these paremeters and use them to generate your output. Once again, it escapes me why Layar sends this data to your webservice, rather than doing the necessary calculations in the app itself. I can only guess it’s to do with performance issues.

SimpleXML

What I did was use PHP’s built in SimpleXML features to pull the google map RSS feed apart, and take out the longitude, latitude, title, and description data out.

Doing this is pretty easy. You call something like this:

$xml = simplexml_load_file('http://maps.google.co.uk/maps/ms?.......');

and go through each point-of-interest with a loop like this:

foreach ($xml->channel->item as $entry) {....

Scary maths bit

Remember those 3 input parameters? Longitude, latitude, and radius. The reason they’re passed to your webservice is that Layar needs to tell your webservice not to bother sending irrelevant results back to them. Suppose the user only wants results in a 1km radius. Layar doesn’t want a mass of data covering most of England. It’d just be too slow.

Soooooo…. you’re going to have to do some scary maths to calculate distance from a point. All that nasty trigonometry stuff you did at school.

Don’t panic! The Layar people provide you with the formula. In case you can’t find it, here it is:

$distance = (((acos(sin(($value['lat'] * pi() / 180)) * sin(($lat * pi() / 180))+cos(($value['lat'] * pi() / 180)) * cos(($lat * pi() / 180)) * cos(($value['lon']  - $lon) * pi() / 180))) * 180 / pi()) * 60 * 1.1515 * 1.609344 * 1000);

where $value['lat'] and $value['lon'] are the user’s coordinates, and $lat and $lon are the coordinates of the point-of-interest.

You just need to compare this $distance value with the user’s radius GET parameter sent by Layar.

JSON output

Your final output, then, is nearly ready. Build a PHP array containing the layer name and a list of the points-of-interest. Each point should have coordinates, a distance from the user, and other data like title, description, image URL, etc. Full details on these can be found in the Layar wiki and tutorials.

The last thing you need to do is make sure your webservice output is in JSON format. In PHP this is too easy: just call json_encode() with your array as the parameter.

Test and publish

Once your webservice is up and running, go and test it from the Layar developer area. I haven’t as yet published a layer, but it seems to involve a fairly straightforward submission process.

One cool (although thinking about it pretty essential) feature is that you can test your layer in the Layar app itself. Once you have a developer account you get an extra “test” tab in the app. This lists all your own layers, each of which will function exactly as though it’s been published.

Summary

The Layar augmented reality app is a really nice idea, and one which allows developers to build their own layers relatively easily. You do, however, have to be a developer with some knowledge of webservices and familiarity with APIs. It’s just a shame the Layar people didn’t think to allow very small-scale layers pulled directly from, say, Google Map RSS feeds. The only reason I think they’ve not done this is for performance reasons. But if all you want to do is build a layer with a couple of dozen points of interest in a limited area, the whole radius/distance calculation thing seems a waste of effort on the developer’s part.

On the plus side, once you’ve developed one simple layer it’s incredibly easy to modify your code to build other layers. In fact, all you really need do is pass in a different Google Maps RSS URL.

Another plus, of course, is that Layar removes the need for developers to get involved in actually building their own iPhone augmented reality apps. A far scarier prospect than that distance calculation.

iPhone dev image processing quirks

I had a lot of problems getting image processing to work properly on the iPhone. This isn’t so much because the image processing I was doing was very tricky; it was more because of some apparent quirks in how the iPhone works its image orientation.

Basically it seems that if you take a photo in portrait ie ‘up’ the iPhone thinks you’ve taken the photo in landscape ie ‘right’. Weird. But that’s how it seems to work.

In fact, no matter which way round you hold your iPhone, it always thinks the photo was taken 90 degrees clockwise from what it actually was.

In my app, I’m taking the raw image as a UIImage and converting it to a CGImage to do various things at the pixel level, and converting it back to a UIImage. As part of this I’m now therefore having to rotate the CGImage round, using code like this:

// iphone held up
if (uiimage.imageOrientation == UIImageOrientationRight) {
context1=CGBitmapContextCreate(m_imageData, m_width, m_height, 8, m_width*sizeof(uint32_t), colorSpace1, kCGBitmapByteOrder32Little|kCGImageAlphaNoneSkipLast);
CGContextSetInterpolationQuality(context1, kCGInterpolationHigh);
CGContextSetShouldAntialias(context1, YES);
CGContextTranslateCTM(context1, m_width/2, m_height/2);
CGContextRotateCTM(context1, -M_PI_2);
CGContextTranslateCTM(context1, -m_height/2, -m_width/2);
CGContextDrawImage(context1, CGRectMake(0, 0, m_height, m_width), [uiimage CGImage]);
}

This first detects which way round the iPhone thinks the photo is so we can do the right kind of rotation. It then uses CGContextTranslateCTM and CGContextRotateCTM to rotate and shift the image around in the image context space, before drawing the image into that space. Note that CGContextTranslateCTM is needed because CGContextRotateCTM rotates an image about its top left corner, not its centre. We therefore need to shift the image around if we’re ever going to see it.

The even weirder thing is that all this image rotation is unnecessary if you allow users to crop the image just after they’ve taken a photo, using the iPhone’s image picker. Obviously Apple built this kind of functionality into the image picker. The only problem with that route (which I used in my earlier Phlomo app) is that you end up with a rather small, poor quality image, and an extra unnecessary user step.

Twitmo iPhone app

twitmo iconI’ve been working on an iphone app called Twitmo which lets you take a bog-standard iPhone photo, and turns it into something a bit more interesting. You can then write a tweet by tapping on the image, and send the whole thing off to Twitter. Well, to Twitpic actually, but it’s effectively the same thing.

The philosophy behind Twitmo is the same as my earlier app, Phlomo: take quick Lomo style snaps of whatever tickles your fancy, and upload them quickly and easily to a social networking site. In this case Twitpic and Twitter.

It’s been a long, hard fight getting this app ready, mainly because of problems with image processing. Basically the iPhone has a very weird way of knowing which way up a photo should be. If you want to do real image processing this creates real headaches. I got round it in Phlomo by letting the user use the iPhone’s built-in crop, just after a photo’s taken. I don’t know how this fixed the problem, but it did. But a number of people complained that the resulting image was small and poor quality.

So, with a lot of late-night trial and error I finally got the image processing sorted.

Uploading an image to twitpic is easy. Although I’m slightly concerned that twitter are phasing in OAuth, but twitpic have made no noises about when they’re falling in line with twitter. I guess sometime later this year I may have more coding to do…

Phlomo

ok so I’ve renamed Flomo to Phlomo (there’s a toy company in the states called Flomo) and I’ve submitted the app to Apple. Fingers crossed. The whole testing and submission procedure was a bit of a pain. But now I’ve done it, it doesn’t seem too bad.

I can’t think why the app might not be accepted, although Apple are notorious for accepting the most incredible dross and rejecting perfectly good apps on minor technicalities (such as incorrect age ratings based on their bizarre criteria).

I’ve also set up Phlomo.com.

Oh and I’ve tried out this new theme, which I think is somewhat better than the last.

Flomo iphone app

icon.pngA few weeks ago I decided to start playing around with iPhone app development. It would, I thought, be a relatively straightforward thing. Even small children could do it.

But what to choose as a test project? Perhaps something stupid that made some kind of farty noise each time you shook your iPhone? Nah… build something useful Matthew. Something I and others like me would want to use.

Uploading images to Flickr seemed like a cool idea. There are some really nice apps out there that do this already. Hmmm…

Another thing was simple image manipulation. You know, make your crappy iPhone photos look like you took them with a Lomo ie turn them into something bad yet cool. Already done. Hmmm….

I know – combine the two! Brilliant idea! Let’s call it Flomo (flickr + lomo). Lame name – yes. Arsed to think up a better name – no. I even designed a funky logo (above).

Turning the idea into reality has proven to be somewhat more tricky than I’d thought. Trying to run before learning how to walk is a cliché that springs to mind. But it’s been a useful lesson in iPhone development.

Specifically it’s taught me:

1. How to access flickr’s API. Authentication with their API is like sticking hot pins in your arm at the best of times, never mind in an unfamiliar language (Objective-C).

2. Objective-C doesn’t have a simple way of doing MD5 hashes. It’s a pretty much build your own kind of thing. Ugh.

3. How to process images. Thanks to some online help and general banging-head-on-wall type thinking, I’ve finally realized that image processing isn’t all that hard. Neither is it easy. Finding stuff on forums like (I paraphrase) “listen you newbie scum, this kind of thing is so trivially easy I’m not even going to explain how to do it” didn’t help. But I got there. I’ll publish relevant bits of my code in the next post.

4. Multithreading is really useful. Do you want a nice spinny wheel thing while the image is uploading, so your user doesn’t think the app has broken? Well you *have* to use multithreading. Obvious if you know that it’s obvious. Like so much in iPhone world.

5. XML parsing? Not easy and not fun. Just parsing a simple web service response is bad enough. Making any sense at all of complex XML seems like far too much hard work. PHP SimpleXML – I love you!

There are all kinds of other bits and pieces which I’ve had “fun” with. I’ve probably implemented them really badly. But I don’t care. I have an iPhone app which works. Just a little more work and it’ll be ready to submit to Apple and wait months before it ever appears on the store for free.

Oh, and those news reports about small children coding for the iPhone? Two words: parental guidance.

Beginning iPhone Development: Exploring the iPhone SDK

iPhone development isn’t really all that much fun, but the end results can be very cool. Dave Mark and Jeff LaMarche have written a really nice introduction which makes the whole process seem just about manageable. Almost cool and quirky even.

Importantly, it successfully captures the key to the iPhone’s success as a development platform: anyone with sufficient determination (yes, you!) can get through the unnecessary and bizarre horrors of Objective-C and the iPhone SDK, and can produce something that people might pay some money for. It’s something you can almost impress people with at parties. Almost.

Of course the book has an online forum and downloadable source code – de rigeur for coding books these days, but good to see nonetheless. In summary, if you want to try your hand at some simple iPhone apps, you really will need this book.


iPhone 2.2 and how not to build a user-interface

Am I totally brain-dead? Or am I just getting old and no longer able to cope with technology?

Probably both. Whatever the answers, these questions popped into my addled mind this morning after I’d excitedly updated my iPhone’s software from 2.1 to 2.2. “Excited” is perhaps too strong a word, but I was hoping for some new iPhone features to play with for 10 mins or so.

I’d heard about street view coming to the iPhone. Although we don’t yet have this for UK cities, it’s still fun to play around with. So where was this bright new iPhone future? I mean, you go into maps… and… no new buttons. Nothing saying ‘press for street view’, no options saying ‘turn on street view’.

Apple’s site in fact proudly announces the arrival of street view to the iPhone. There are photos of it there, and it’s working on their demo phone. What about on my phone?! I was clearly missing something obvious and had just become an Old Man overnight.

So after half an hour of searching on google I find some blog somewhere mentioning something about dropping a pin and pressing a tiny red man somewhere. Huh? The plot thickens.

Surely this can’t be true? Have Apple gone mad?

“Oh yes it is”. And “oh yes they have”.

Really, it’s true. To use a lovely new built in feature like Google Street View on your iPhone you actually have to arse around with a pin thing and a tiny icon of a red man that only appears when you drop the pin. Even worse, you have to press a button to get to the page which lets you drop a pin. And then press another button to drop the pin.

One… two… three… 

So that’s three button presses to get to street view? None of the steps are at all obvious. And pressing that little red man icon thingy? Yes, that’s really obvious…

Apple have clearly ditched any attempt to make interfaces intuitive in favour of making it a requirement to read an explanation first. This is the kind of thing some crazed nerd might do. Not Apple. Not the company that Jef Raskin once worked for. Not the makers of OSX and the iMac and the original iPod.

Phew… rant over. Sorry.

Well, not quite. That other new feature: podcast live downloads. In principle it’s simple: you search for a podcast on the go, download it, then listen to it. Nice idea. Trouble is – again – that the user interface is just bizarre.

You enter podcast mode in the iPod app. Press a “get more episodes…” button which takes you to a different app, where you download the podcast or search for something different.

There are some nagging questions though:

  • How do I get out of podcast app and back to iPod? Hmmm, press the Home button and press on iPod. Not brilliant design really.
  • And how do you delete old unwanted podcasts that you just downloaded? Well, you don’t. Unless of course there’s some other hidden icon of a red man or you have to guess some combination of button presses.

All in all, Apple’s tried to add in a few new features with the 2.2 update. They’re nice features, but just a bit weird and poorly thought out.

Expect 2.2.1 fairly soon because unless my brain really has died, surely others will be asking the same questions and wanting answers.