Creating an Android app for the color vision impaired

For those who don’t know, I’m partially colorblind.  It is only occasionally an issue, usually because of something being color coded.  Asking strangers what color things are is embarrassing.  (“Excuse me, is this pen red?”  Good thing I asked, though.  It turned out to be orange.)  It occurred to me that I walk around with a camera in my pocket all day, and I could use that to determine colors for me.

Diving into Android development was surprisingly easy.  Of course, I’m a veteran Java programmer, I’ve worked with embedded devices before, I already had Eclipse set up, etc.  The API needs more documentation, but that’s not a rare deficiency.  There are also a few random warts.  I started with a camera preview demo on Google’s web site.  When I forgot to add the camera permission to the app, I got an out of memory exception.  I’m glad I started with that demo, because this was a common issue and reported all over the web.  Otherwise, I don’t know if I ever would have figured that out.

Speaking of finding things on the web, the Android community seems to be quite healthy.  There are a lot of people, and many of them make contributions such as offering fixes or workarounds.

The SDK supports debugging over USB, but my computer’s USB is flaky.  I ended up copying the app to my website then downloading it on the phone.  I had to change a setting to install apps that aren’t from the market, but it was a simple checkbox.  Now I just open the file and it installs.

There is a particular issue I’ve run into dealing with the camera preview.  The only supported format (currently) is YUV420 (or 422, not sure which), which has a complicated way of packing pixel data into a byte array (compared with RGB, anyway).  The Android standard BitmapFactory is unable to parse this byte array, possibly because it lacks a header of any kind.  There is a bug report filed, but apparently the issue has yet to be addressed.  On the bug report (and elsewhere) there is code for converting YUV to RGB.  It seems to work on the emulator as far as I can tell.  On my phone (a Samsung Moment), though, the byte array doesn’t seem to be long enough.  For better or worse, I’ve resorted to taking a picture and pulling the data from it.

Overall, it’s been a positive experience.  There are certainly improvements that need to be made, but I was amazed at how quick and painless it was to throw something together and get a working prototype on a phone.  It also did not require buying a Mac, paying $99, and going through an approvals process just to be able to prototype an app, as the iPhone does.  You do have to pay $25 to be able to publish apps on the Android Market, but you can distribute your apps for free outside the market.  (Admittedly, your user base would be much smaller.)

I would like to thank Randall Munroe, author of the xkcd webcomic, whose color data is used in the app to convert RGB values to names.

The app (named “Color Vision”) is available for download now from the market and is also an open source project on SourceForge.

2 Comments

  1. Posted July 3, 2012 at 2:24 am | Permalink

    hi mr adam i would like to ask some questions in making this application, if you won’t mind please send me an email thank you.

  2. Posted February 3, 2013 at 10:20 am | Permalink

    Hello,
    Your app, with the open sourcecode is a precious help for me to realize
    a app, in which I also want to get rgb values from specific points.
    Like you describe, the effort is to convert the YUV to RGB.
    I will try it with the Code from the KETAI project.

    So thank you for your project!

Post a Comment

Your email is never shared. Required fields are marked *

*
*