A few months ago I bought a smartband. The main idea being prosaic - I wanted to receive notifications from a smartphone as well as have a good pedometer. A few weeks after the purchase, the same company came out with a new version of the device that included one great feature… a heartbeat detector.

I would not be a true developer if I didn’t try to write an add-on for this one, right?

I went through the very first requirements. Dug deep into the app architecture. Actually it took me some long, long night hours (I should probably spend sleeping…). BUT, I finally came up with an idea tailored perfectly for a regular smartphone user.

For my concept I required a few things: a flashlight, a physical camera and a non-trivial algorithm.

The main profile of the person using our healthcare application is a normal smartphone user (not a power user, only an average person without any technical know-how). First, I thought about a cross-platform application, but after a few hours of reading about Ruboto integration with the camera API, I decided to create an IoT application in native Java.

How our health app works

The application uses the API to fetch the frame from the camera. Every valid image is processed (NV21 method) and the most interesting parameters are stored. Next, the algorithm compares the frame with latest cached frame, and (again) the results are stored.

The main issue at the beginning of this idea was to compare images. In my programming experience, I hear all the time about the expense of an operation that compares pictures, but I was not going to give up easily.

This problem encouraged me to improve and optimize this service. After 2 weeks of testing, I found a new solution.

Calculating the number of red pixels in an image is the most important thing! When I tried to detect a heartbeat, I needed only the number of red pixels from the image. If the number is higher than in the previous image (for example, 10 frames), then I can assume that the heart is now beating. Why only red pixels? Blood is, of course, red and so blood and a flashlight directed on a finger should give a very bright, red image. We don’t need anything else.

#iot #product design #development

IoT Healthcare App: Heartbeat detector using phone camera
1.15 GEEK