Simon Fletcher
Feb 8, 2017 · 6 min read

* Before the spelling police arrest me: this post relates to an AWS AI deep learning-based image recognition service called Rekognition.

OK, I’ll admit I didn’t actually write the facial recognition bit of my app. But, I did find out how painless, quick and incredibly cheap it is to add facial recognition to your repertoire. Plus, I did get you to click on this article…

As soon as I saw the release of Rekognition back in early December 2016, I wanted to play with it but just didn’t have the opportunity at the time. A few weeks later, I read the famous post about building Jarvis from Mark Zuckerberg. And, guess what, the facial recognition part stood out to me once again.

At the time I thought to myself: Imagine being able to open the door from my sofa! Lazy I know, but exciting to me all the same. Or, a more practical example of the same implementation. Imagine a door entry system for shared workplaces where each company could be notified of a visitor, purely based on the face of that person being in their database?

A month later, I was sitting watching the news on the day of Donald Trump’s inauguration, and I heard one presenter say: “Trump will now take hold of the nuclear codes.” A chill went down my spine, but soon after, I wondered: “Why do we have codes in 2017?” Codes are a format that could easily be updated, forgotten or lost entirely. Why not use something which only allows the President to gain access to this weapon of mass destruction? So that is when I thought to myself: “I can create this, no problem.” So that’s what I did (with a little help from AWS).

I wanted to create an app which would take a picture of the person sitting in front of the camera and swiftly let them view the “nuclear codes” * if they passed validation by facial recognition. While this was the aim of the physical application, I also wanted to answer the following questions about the AWS Rekognition service itself.

*Disclaimer: these would not be the real nuclear codes, that would be insane

1. How easy is it to implement the API?
2. How reliable is it?
3. Is it scalable?

The App

Put simply: the app doesn’t do a lot. It provides one with a button to validate the person who is sitting in front of the camera. If the face passes validation by over a 90% similarity threshold, the app redirects to let the user see the “nuclear codes”.

I also made use of another AWS AI service called Amazon Polly, which, to quote AWS:

Turns text into lifelike speech using deep learning

I used Polly to provide an audio prompt to the user instead of visual prompts. Again, this was just me getting carried away with how easy it was to integrate with another one of the AWS AI services.

That is it. There’s not a lot to it so you can see how it only took two hours to pull together a rough implementation.

Now, unless you’ve stolen my face — and if you have, I’ll be furious — trying this app won’t be very exciting for you, as of course, it should block you from seeing the codes. If you are interested in testing it out, I would suggest you checkout the Nuclear Codes GitHub repository, and follow the “How can I try it out?” instructions at the bottom of the README to get it up and running on your local machine.

The stack

I have wanted to explore combining React and Electron for a for a while, so I decided to do just that. And the outcome was a desktop Mac app (although it is not published on the Mac store, again, this would not be very useful). There were a few dependencies (such is life with the JavaScript ecosystem), but the two most important libraries were:

  • webcamjs — It’s a super simple library that allows you to access and take snapshots through the webcam on the machine.
  • AWS SDK — Provides a super simple DSL which allows you to make clean and straightforward API calls to AWS services.

What is the outcome?

I’m not suggesting the Trump administration implements this immediately, not least because a picture of the President’s face held in front of the camera would allow anyone access the codes (not 100% ideal when nuclear bombs are involved). But, with mild security concerns aside, let’s move on to explore the questions I wanted to answer myself.

1) How easy is it to implement the API?

As I described in the stack section, I made use of the AWS SDK which made this super simple. Let me give you an example of the code that would provide facial recognition for you:

let rekognition = new AWS.Rekognition();
SimilarityThreshold: 90,
SourceImage: {
S3Object: {
Bucket: "rekognitionnn",
Name: "nuclear-codes/source.jpg"
TargetImage: {
S3Object: {
Bucket: "rekognitionnn",
Name: "nuclear-codes/target.jpg"

That is it. No really, that is it. You get a response which you can check to see if there is a match, and if there is, the response gives you some details. But ultimately, in my instance, all I wanted to achieve was: Does it match or not?

2) How reliable is it?

I can only talk from my experience, but it is pretty damn reliable. You can change the `SimilarityThreshold` to allow flexibility around this, but I found that 90% was a good match for taking various images in diverse environments, from varying angles and different distances.

3) Is it scalable?


With Amazon Rekognition, you only pay for the number of images you analyze and the face metadata you store.

As with all AWS services, you pay for Rekognition on the tiered pricing model. The pricing is a pretty sweet deal as well; you pay $1 per 1,000 images for the first one million images. I have been testing this on and off quite regularly for the past week. It has cost me 5p.

But there is more…

Although I have called my approach to this “facial recognition”, AWS calls this feature “Facial comparison”. The Rekognition service provides two other pretty amazing features which could potentially be very powerful, and provide new business opportunities for some.

Detection of objects and scenes

Image Source:

Recognition identifies thousands of objects such as vehicles, pets or furniture and offers a high level of trust. Recognition also detects scenes within an image, for example a sunset or beach. In this way, you can easily add features that allow you to search, filter, and curate large image libraries.

Facial analysis

Image Source:

With Recognition, you can recognize faces within images and analyze facial attributions, such as whether a face is smiling or eyes open.

Facial recognition

Image Source:

With Recognition, you can find similar faces in a large collection of images. You can create an index of the faces that were detected in your images. The fast and accurate search function of recognition recalls faces that correspond most closely to the reference face.

I can hear mild cries around the privacy implications software like this. Something like, “Does this software use my images to train itself?”. At which point, I would like to point you towards the Rekognition FAQs which will hopefully put your mind at ease. To address the question above directly — AWS do not use your images for training unless you provide explicit consent that you would like your images to help improve the software.

And one final thought. Mylio estimates that around 1.2 Trillion photos will be taken in 2017. I will now let you sit back and come to your own conclusions as to how influential these services could prove to be in the next few years.

Mint Digital

Mint creates new companies and transforms existing ones

Simon Fletcher

Written by

The ramblings of a software developer currently writing code on behalf of @mintdigital.

Mint Digital

Mint creates new companies and transforms existing ones

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade