Coder Social home page Coder Social logo

7-ush / heart-rate-api Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 5.0 1007 KB

Heart-Rate-Api to estimate Heart beats per minute using PPG data

Home Page: https://heart-rate-07.herokuapp.com

Procfile 0.42% Python 99.58%
opencv python3 scipy-signal flask-api-rest

heart-rate-api's Introduction

Heart Rate API

A simple API to estimate heart rate using PPG analysis data from mobile camera.

Use

  • Record a 15 second video by keeping finger over the camera with flash on.
  • Send url link of video to the api to perform PPG and estimate heart rate.

Approach

  • Place finger over the camera and 15 second video was recorded with flash on in each case.
  • This video is imported to our python based api using open cv2 and video object was created, FPS, frame count were determined.
  • The first few frames and last few frames were dropped as a data pre processing measure as they contain most of the error. eg. placing finger and removing finger, stablizing time etc.
  • For each image of the video, pixels in the middle were selected and average of RGB colors were calculated.
  • Array of each RGB color was maintained to storage average values.
  • Array with red pixels was selected for further processing and determination of results as red color gives best result (Assumption)
  • Following arrays were treated as signal objects.
  • Lowpass filter and highpass filter is use to remove unwanted frequencies from signals.
  • Further, signal was squared to elongate it, so that it was easy to determine peaks (Assumption)
  • Peaks were detected using peak detection algorithm from SCIPY.SIGNAL library and average time between peaks were calculated.
  • Thus, calculating Heart rate.

Deployed API link

https://heart-rate-07.herokuapp.com/api?query=video_url_link

The query must contain url link of ppg data captured using mobile camera with flash on.

Example of API call

https://heart-rate-07.herokuapp.com/api?query=https://firebasestorage.googleapis.com/v0/b/heart-rate-monitor-cee6e.appspot.com/o/files%2Ftest.mp4?alt=media&token=61d6c17c-4f85-4c32-b9a7-7ea0fd19400c

Example of API response

API response example

{
   "r_avg":[
      0.00018912736029968232,
      0.002454027341541433,
      0.0046238379461607014,
      0.0059273051392782815,
      .....
   ],
   "g_avg":[
      5.739757749447178e-05,
      0.002728729471758443,
      0.005252370906011639,
      0.006246822018310483,
      .....
   ],
   "b_avg":[
      0.00012713453865537887,
      0.0009398674441625056,
      0.001593039182660829,
      0.0019041612619612055,
      .....
   ],
   "r_bpm":131.9763664543775,
   "g_bpm":112.5044435348792,
   "b_bpm":104.61541243334804,
   "avg_bpm":116.3654074742016
}

References

heart-rate-api's People

Contributors

7-ush avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.