Skip to content

ganeshkumartk/heartpi

Repository files navigation

HeartPi ๐Ÿ’“๐Ÿ–ฑ

๐Ÿ’“๐ŸŒกIoT based Heart rate measurement using Raspberry pi, OpenCV and Thinkspeak dashboard


Monitoring of Heart Rate is a necessity in almost all the telemedicine fields. The cost of external sensors and the presuure appied by the sensors on the fragile skin of children and old age people invokes the demand for contacless monitoring of Heart Rate. The same can also be used for future research in Stress Monitoring, Measuring attentiveness while watching a video tutorial.

This Project developed records the live video of a single person using Raspberry Pi & Camera and gives a real time graph with the heart rate value in beats per minute. The values get automatically stored in a csv file for future use. The model also makes a person aware for high heart rate by Realtime Dashboard via ThinkSpeak API.

Table of contents

Technology behind

Remote photoplethysmography (rPPG) enables contactless monitoring of human cardiac activities by detecting the pulse-induced subtle color variations on human skin surface using a multi-wavelength RGB camera. In recent years, several core rPPG methods have been proposed for extracting the pulse signal from a video. These include the following:

  • Blind source separation (BSS) (e.g., principal component analysis (PCA)-based and independent component analysis (ICA)-based, which use different criteria to separate temporal RGB traces into uncorrelated or independent signal sources to retrieve the pulse
  • CHROMEANCE, which linearly combines the chrominance signals by assuming a standardized skin color to white-balance the images;
  • PBV, which uses the signature of blood volume changes in different wavelengths to explicitly distinguish the pulse-induced color changes from motion noise in RGB measurements
  • SR, which measures the temporal rotation of the spatial subspace of skin pixels for pulse extraction.

Pi-camera

rPPG Implementation via Blind Source seperation (PCA & FastICA)

Usage

  • Connect your Pi Camera in Camera slot using Camera cable. Once installed test your pi camera for brightness and adjust. See reference
raspistill -o Desktop/image.jpg

Pi-camera

Raspberry Pi connected with Picamera

๐Ÿ‘‰ If your connecting your Usb camera, skip the first step and go ahead as Pi automatically installs drivers for camera.

Project Setup

Project setup

Project setup

  • Open CLI(cmd prompt)/Terminal

  • Git Clone this repo

git clone https://github.com/CoDeRgAnEsh/heartpi.git
  • Do not have GIT? Download this as zip folder from Right Corner Option and extract it

  • Open the directory of Cloned repo/Extracted folder

cd heartpi
  • Install Python3.7 (Works on Python 3.7+ as some libraries are depreciated in Py2.7-Py3.5)
sudo apt-get install python3 python3-pip
  • Install dependencies
pip install -r 'requirements.txt'
  • Open Heartrate.py & Place Your Thinkspeak IO Credentials(if you wish to stream to your Dashboard) and Save.
key ='YOUR_WRITE_KEY'
  • Place the haarcascade_frontalface_default.xml file for face and forehead detection, if you wish to change the path you can update
face_cascade = cv2.CascadeClassifier('/home/pi/<your-path>/haarcascade_frontalface_default.xml')
  • Run Python script to get working at Raspberry Pi
python3 -W ignore Heartrate.py

ScreenShots

Heart rate Testing Pic

(a). Heart rate Testing (via SSH using VSCode ext in pi)

Heart rate Power graph

(b). Heart rate Power Spectrum Graph

Heart rate Power graph

(c). Heart rate variation mapped in RGB Channels using PCA & FastICA

Heart rate Power graph

(d). Heart rate updated live in Thinkspeak Dashboard

Project Report

IoT based Heart Rate measurement system in Raspberry Pi, OpenCV and Thinkspeak dashboard

Credits

Issues

Facing issues, Pour here.

Contribute

Fixing issues and Upgrade, Pull out PRs.

Contact

Mail me msm17b034@iiitdm.ac.in

About

๐Ÿ’“๐ŸŒกIoT based Heart rate measurement using Raspberry pi, OpenCV and Thinkspeak dashboard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages