25.5.11

iPhone camera: Removing the green blob




It all started on a hot spring day in Barcelona. I waited for the subway to arrive, and spotted this beautifully rugged shaft. First, I shot it with my phone*, then realized I still had time for a "proper" shot and took another picture with my camera. That's when I realized that, in comparison, the photo from the iPhone 4 showed a large green spot in the middle, and slightly pink corners.


Once the subway had arrived, I browsed through my photo collection - and the realization was stunning: green blobs everywhere!



In some shots, the effect was subtle, in some, extremely striking (as in: every shot of a white screen). And it wasn't just my phone: Green blobs are all over flickr, too.










So, now that I've trained you to see green blobs in all of your photos (hehe), I'll also provide an easy way to remove them.


Take this (right click and "save link as") inverted green blob, and throw it, together with your photo, into your favorite** image manipulation suite. The blob becomes the top layer, and should be set to "overlay" (or, in lack thereof, "multiply" will also do). Immediately, you'll get a hue-corrected, and much more natural picture.



*not without being yelled at by a rude construction worker, for taking "illegal" photos. People in Barcelona are less friendly and helpful than in any city I've ever been - and that's from a German's point of view! My photos survived just because the offended guy stood on the opposite platform.

** If you're even more serious about this problem than I am, you could use Imagemagick to correct all your photos with a single batch command. If you already did that, lease leave a photo of your beard in the comments.

24.5.11

iPhone 4 camera specifications




The iPhone 4 features one of the best micro-camera modules on the smartphone market.
Specifically, the backside-illuminated layout is very good at capturing in low-light conditions.
Here's the list of specifications I found or deduced:
  • Vendors: LG Innotek (Packaging), Omnivision (Sensor), Philips (LED)
  • Assembly: Gumi, Korea
  • Physical dimensions: 9.2 x 9.2 x 6.2mm
  • Sensor model: Omnivision OV5650
  • Pixel size: 1.75 x 1.75µm
  • Sensor size: 4.592 x 3.423mm (effective), 6.5 x 6mm (chip)
  • Signal-to-Noise-Ratio: 37dB
  • Dynamic range: 69dB max.
  • LED: Luxeon Flash 6 (color temperature 5500K, light density 230lm)
  • Aperture: f/2.8 fixed (f/22 equivalent on a 35mm camera)
  • Focal length: 3.85mm (30.2mm equivalent on a 35mm camera; 28mm is exaggerated)
  • Crop factor: 7.84
  • Resolution: 2592 x 1944 (photo), 1280 x 720 (video)
  • Sensitivity: ISO 80-1000, maximal sensitivity of 1.3V per lux*s
  • Exposure time: 1/15 - 1/10000s (rolling shutter)
  • Power requirements: 150mA (camera), 1000mA (flash)
Sources: (1) (2) (3) (4) (5) (Sensor datasheet)

Failed: Customizing iPhone "Now Playing" Controls



This is the interface I use several times a day - the "Now Playing" section of the iPhone's lockscreen. Whenever someone talks to me, I have to pause the playback on my phone - and in lack of an expensive pair of headphones, this is a four-step process:
  • Pulling the phone out of my pocket
  • triple-press the home button (the first one turns the screen on)
  • press the "pause" button
  • curse silently because I accidentally pressed the "previous" button, losing the current position of the podcast/music track.
My (seemingly) simple approach was to find the interface definition file of the "now playing" screen and pull the controls further apart. After all, there's plenty of room on both sides, isn't there?
As it turned out, Apple left some room for the (usually invisible) AirPlay button on the right side. So, I would have to move this one somewhere else, or it would be buried underneath the "next" button.

The first step was to find the button itself. As for the third-most intuitive place, I found it under System/Library/CoreServices/SpringBoard.app/nexttrack~iphone.png.

Second, where is the interface definition file? A long, long garden path followed with the .nib files in iPodOut (as the name suggests, this app is only responsible for external displays). As it turns out, the nib2objc project doesn't actually work on those files. Just when I almost decided to hack around with TextEdit, I finally found the correct code fragments: the PNG is used by the NSButton "nextButton". Much to my dismay, it is hard-coded into the springboard binary - and there is no separate .nib for the lockscreen.

Disassembly was suggested to be near-impossible, so I cracked open the file with a hex editor. (Is there any good hex editor for a Mac? I ended up with WinHex I had lying around since 1996 or so) After a quick measurement with Photoshop, the button turned out to be drawn at the coordinates 418,160. WinHex assumed that "418" would be coded in unsigned 16-bit, and searched for A201. There were only 2 useful occurences, and both didn't have "160" (A0) in the close vicinity. I replaced them anyway (with "546") and replaced the binary on my phone. After the reboot, I wondered why it didn't crash (maybe the replacing process didn't work while SpringBoard was running?) - but the controls hadn't moved, either. I closed WinHex and called it a day.

The day after, I still felt like I was almost at the finish line - just finding the correct "418" would be enough to complete this project. But I started out with a more generic search term, and found a much easier solution: Assigning the home button to the iPod Play/Pause key.
The tool Activator allows an assignment exclusively for the lockscreen, where the home button hasn't had any function before.
Now, my four-step workflow is reduced to this:
  • Push the home button twice quickly (without even looking) to pause playback

12.5.11

Micro mixer for two audio inputs


Recently, I drove along on the Autobahn and listened to an audiobook. Suddenly, I got a slight crave for one certain song - but I didn't want to stop listening to the book. Because my phone can't (comfortably) play two audio files at once, I needed two devices for this job. But even when I gathered two audio devices (a phone and an iPod), my car radio has only one input port.

The initial question was "How do I get a second AUX port for my radio?", which quickly evolved to "How can I combine the output from two audio devices onto one cable?".
The usual solution would be a mixer - a bulky and expensive device. I didn't need the large crossfader, or even volume control - both my phone and my iPod can do this on their own.
So, after a bit of google-fu (and a lot of experimenting with resistors), this is what I built:

The blue part just amplifies the signal from the phone by a factor of 20 - a luxury that allows for resonable volumes without cranking up both the phone and the car stereo.
Of course, you'll need two of these to get stereo sound.
If you're going for the least effort, this would be your prefered circuit:
This version (again, you'll have to build two of those) doesn't even need a supply voltage. If you don't have 220µF capacitors lying around, preferably go for something bigger - everything below 100µF will muffle your base sounds. The polarity of the capcitors doesn't matter; they're going to be driven the wrong way half of the time, no matter the polarity. Voltage rating allows for everything above 3V.

The cover image shows the final circuit, built directly into the radio chassis (there was a lot of space after I removed the cassette module)