The Bank of America Building of Atlanta

I had a fun dev idea yesterday afternoon when driving my wife to the 'port: generally the concept is some sort of AR app where you show the Bank of America building in your screen from a camera view, and it figures out how far away you are from it based on knowing how big it is and doing extrapolation.

The building is a dominating feature of the Atlanta skyline. A comparable use case for New York would be building the same app for the Empire State Building or the Freedom Tower, for example.

I was in the middle of my work day, and had daycare pickup duty and whatnot ahead of me, so I wasn't able to dig in right away, but I did some preliminary research, and there are plenty of links with similar, but not super-specific information about the actual dimensions of the building.

I did reach out to try and get some more specific intel:

Still no word back yet ...

After further thought, I figured that maybe another fun task would be using a few different pictures of the building from known vantage points to try and figure out it's height, or perhaps heights of specific components such as the spire.

After dinner, bathtime, nighttime routine, cleanup, and some more work, I started jotting down some notes, trying to recall my middle/high school trig ("Some Old Horse Caught A Horse ..." - that's trig, right?):


Disregard the angles and all of that shit, the actual solution I was looking for is in the box to the bottom right. Essentially, you can approximate how far you are from the building if you know the ratio of actual distance based on the number of pixels long an attribute of it is in an image.

In my example, when 3.070 km away, the spire is ~28 pixels long. when 0.663 km away, the spire is ~128 pixels:

screen shot 2017-09-18 at 11 18 17 pm screen shot 2017-09-18 at 11 18 23 pm

So in other words, if you can figure out how many pixels the spire is on your camera, you can guess roughly how far away you are.

It was a bit of work getting these distances and pixel measurements, though. I have some photos I've taken from my time in Atlanta so far that have the building in the background, so the next step was figuring out the GPS coordinates of these photos. While this isn't the MOST straightforward thing to do, I did end up figuring it out after a bit of research. I needed a proper Exif metadata extractor, and some glue to pull it all together. I ended up writing this stuff. I probably didn't have to come up with a re-useable tool, but I figured, why not?

Now any sensible person would stop there and say OK, cool. If you want to know how far you are from the building, just use your phone's GPS to calculate the distance. But I was on a roll!

I started thinking, how hard could it be to build a simple little app with a spire that you can pinch-zoom that displays an approximate distance based on matching it up with the actual size of the spire?

That got away from me quickly. Several hours later (after 1 AM on a school night!), I actually got a working version of drawing an image overlay over the camera with a bounding box that measures the height!

Here's an example of what I mean:


(imagine you can pinch-zoom to make the green box bigger or smaller. Also the size reporting is in the Android logging for now)

This is clearly just a proof of concept to show that it's doable, and potentially worthwhile (?). Don't get too excited.

To get to this point I went on a bit of a tour of Android's new(ish) camera2 API for working with the camera. This app specifically is built off of this nice android-Camera2Basic example app. It's not in any sort of publishable state, but there are a ton of posts on Stack Overflow looking for similar camera overlay functionality, so maybe I'll submit a PR at some point.

TODO going forward if I wanted to keep developing this thing:

  • Add an actual display of size in pixels and estimated (vs. actual?) distance based on GPS
  • Modify the overlay to be the shape of the building
  • Build in some sort of calibration to figure out the exact ratios based on the phone's GPS/camera

Anyway, that's all for now! 👋