2020 04 03


Reading time: less than 1 minute

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.

Theory

  • 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.

Implementation

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.

Citation

If you find this work useful, please cite it as:
@article{yaltirakli,
  title   = "2020 04 03",
  author  = "Yaltirakli, Gokberk",
  journal = "gkbrk.com",
  year    = "2024",
  url     = "https://www.gkbrk.com/journal/2020-04-03"
}
Not using BibTeX? Click here for more citation styles.
IEEE Citation
Gokberk Yaltirakli, "2020 04 03", November, 2024. [Online]. Available: https://www.gkbrk.com/journal/2020-04-03. [Accessed Nov. 12, 2024].
APA Style
Yaltirakli, G. (2024, November 12). 2020 04 03. https://www.gkbrk.com/journal/2020-04-03
Bluebook Style
Gokberk Yaltirakli, 2020 04 03, GKBRK.COM (Nov. 12, 2024), https://www.gkbrk.com/journal/2020-04-03

Comments

© 2024 Gokberk Yaltirakli