Is the battery charged? Is the broadband connection up or down?

If you have red/green color blindness, these questions can sometimes be hard to answer.

General color finding apps are available but I have found them lacking for reading LEDs:

  • they only sample color from a small target area and are hard to aim; making this worse, LEDs tend to be overexposed by the camera and must be sampled around the perimeter to get an accurate color reading
  • they don’t allow you to read multiple LEDs at the same time
  • they don’t handle blinking LEDs well
  • they display colors from a large palette of color names instead of giving a simple red/green answer

What’s needed, I thought, is a simple app that does just one thing: point the camera at some LEDs and the app finds and labels them red or green (or blue). Surely this must be possible with today’s computer vision technology.

So, I grabbed OpenCV, spent some quality time with google and stackoverflow, tried several approaches, and settled on a simple algorithm that seems to work pretty well.

I developed the algorithm in opencv-python and then ported it to opencv.js, building an app that runs in a mobile web browser and processes live video from the front-facing camera.

Try the mobile web app here

All of the code is on GitHub