EXIF Parsing Fun

I’m thinking about replacing my Olympus OM-D E-M5 as a travel camera. The Olympus is great and has served me quite well on my trips, but I’d love to get something with faster autofocus and with better low light performance. Current frontrunners in no particular order include the Leica Q, Sony RX1R II, Fuji X100T, and Sony A7S II. Since these are mostly fixed lens cameras, the most obvious differences in deciding between these cameras for me is the focal length, with the exception of the A7 of course. All of this got me thinking – at what focal length do I most like taking most of my photos? The Leica Q is 28mm, and the RX1 and X100 are 35mm, so I should probably figure that out.

I decided to quickly tackle something that I’ve wanted to do for a while but never got the chance: write a quick Image Reader App that can extract EXIF data from photographs and do a simple unique count of the focal lengths.

I did some searching to see if there were any existing libraries that did some EXIF parsing and decided on this one, by a smart guy named Drew Noakes. Even better, it included support for both of my cameras which are a Canon 5D Mark III with 24-70 f/2.8 II and of course my Olympus with the Lumix 20mm f/1.7. It looks like it only supported Java so I threw together a really terrible app that took a directory path and iterated through each photo and did a count. As my sampling, I decided to point it at a directory of some of my favorite photos from a trip to Tokyo and Seoul from a few years ago. The results were quite shocking:

{44.0 mm=2, 65.0 mm=1, 41.0 mm=2, 26.0 mm=1, 47.0 mm=4, 40.0 mm=2, 24.0 mm=83, 45.0 mm=2, 61.0 mm=4, 35.0 mm=3, 50.0 mm=4, 38.0 mm=1, 42.0 mm=2, 67.0 mm=1, 59.0 mm=1, 70.0 mm=8, 39.0 mm=2, 31.0 mm=3, 25.0 mm=2, 28.0 mm=1, 33.0 mm=1, 20.0 mm=36, 57.0 mm=5}

Quickly plotted this on a graph:

What this chart tells me is that I love shooting wide angle. According to the stats I’ll zoom in a few times but only rarely. So which camera should I get?

 

Leica Q it is.

For those of you who want to see my code (the single java class in all its glory), I’ve pushed it to a new repository called “Extractor” on my GitHub page.

Wireless Networking with Raspberry Pi

The Raspberry Pi is great and I really enjoy it, but I couldn’t help to think that it would greatly benefit from wireless capabilities. I can only assume for cost reasons they didn’t ship it with onboard wireless networking (the newly announced Raspberry Pi 2 does not have wireless either).

This morning I received the Edimax EW-7811Un Wi-fi USB Adapter in the mail that I ordered a few days ago. (Thanks Amazon for the free Sunday delivery!) A little bit about this USB Adapter – it’s a super tiny thumb-sized USB-based Wifi adapter that is capable of connecting to b/g/n networks that doesn’t require external power. It also runs the Realtek RTL8188CUS chipset which is widely supported by many Raspberry Pi distros, including Raspbian 2014-09-09, the OS that I am running.

Adding the Edimax Nano Wireless USB Adapter doesn't add too much bulk.

Adding the Edimax Nano Wireless USB Adapter doesn’t add too much bulk.

Side shot with the USB adapter installed.

Side shot with the USB adapter installed.

Setup is easy.

Plug in the USB adapter into an available USB port on the Pi, and power on the Pi. You will need a keyboard at the very least, or if you’re running in headless mode, you will need it to be plugged into a network cable so you can SSH remotely into it.

Edit the network interfaces file like so in your editor of choice (emacs, obviously, being the best choice):

You’ll see some configuration in here by default, you’ll want to replace it with the configuration below. You’ll want to type your Wireless SSID and Password in for where I’ve put placeholders (you will want to retain the double quotes):

At this point you will want to restart networking, you can do so by issuing the following command:

From here, running ifconfig will list all of the active network interfaces – if you see a valid IP next to wlan0 then we’re in business; you can disconnect your ethernet cable and congratulations, you’ve cut one more cord from the awesomeness that is the Pi!

As a side note, as normally, ethernet will continue to work as a separate interface. i.e. Raspbian will assign through DHCP an IP to eth0, as well as an IP to wlan0 if both a Wireless connection and Ethernet connection is made. This is redundant so it’s discouraged, but useful in case you are having trouble with wireless and need to fall back onto Ethernet to do some troubleshooting.

Raspberry Pi + HDMI CEC + Node.js

I’m a huge fan of Google’s Chromecast. I’m an even bigger fan of the little-known HDMI CEC protocol originally introduced with HDMI 1.0, which is a spec that allows devices to control CEC-enabled devices through HDMI. This is the technology used by Google that allows Chromecast to turn a TV on from a standby state and automatically switch to the appropriate input when you cast a video stream to the device from a remote client. While this has been a great feature which I frequently use with my Samsung HDTV (Samsung refers to HDMI CEC as “AnyNet+”), it’s unfortunate that there was no option to turn off the TV from a remote client.

After doing some additional research I quickly learned that HDMI CEC is rather capable with what it allows a client device to do and that it does so much more than just turning on or off a device – OSD Display, Device Menu Control, Routing Control, System Information, Timers, Status, to name a few.  I was ecstatic!

After digging even deeper I learned that my Raspberry Pi Model B fully supports HDMI CEC, and the fine folks at Pulse-Eight have developed a fairly mature C++ based library to control rudimentary CEC functions. While this was a great option, it required me to maintain an SSH connection into my Raspberry Pi which was less than ideal (I’m so lazy that I can’t reach for the remote control, what makes you think I’ll SSH in to issue a command line to my Raspberry Pi to turn off my TV?).

rpi

The palm-sized Raspberry Pi Model B computer!

I decided to wrap the lib-cec C++ library in a quick and dirty Node.JS Express Framework app so that I could remotely send commands from my phone over a web server. The core piece of my app is contained here, which enables the “on”, “off” and “status” functions of the CEC protocol, and pipes the output to the web client for the user to see:

The app routes are invoked when the user accesses the URL path for “on”, “off”, or “status”. I modified my Firewall’s Iptables to port forward the app so I can even check on my TV from outside my network, and it works like a charm! I can now control my TV from my iPhone, which means…

achievement_laziness

Full code can be seen in  my GitHub project page found here. Feel free to help me clean it up 🙂
https://github.com/dan-nguyen/hdmi-cec-node-test/