Heart rate from video
I knew about heartbeat sensors that use light, and I have seen Android applications that use your phone’s camera to measure your heart rate.
- Blood absorbs light, and the amount of light that gets absorbed/reflected depends on the amount of blood in the area.
- When your heart beats, the amount of blood in your finger changes, and so does the amount of light that gets absorbed/reflected.
- A camera with the flash on can detect these changes in light if you put your finger on the camera.
I didn’t need to do this live, so I just recorded a video of my finger on the camera using my phone. I then wrote a quick Python script to run the video through ffmpeg to iterate over each frame as an image.
I used the average pixel lightness as a measure of the amount of light that gets absorbed/reflected. When I plotted this value over time, it looked very obviously like a heartbeat. Like a very typical heartbeat, you can’t miss it.
This was underwhelmingly easy. Perhaps a future project could be to do post-process this data with some filters, or to do it live.