File | Date | Author | Commit |
---|---|---|---|
cascades | 2013-04-15 |
![]() |
[b6af0a] first commit |
lib | 2013-08-17 |
![]() |
[6b49cf] Update signalProcess.py |
.gitignore | 2013-04-25 |
![]() |
[ca972d] Update .gitignore |
LICENSE.txt | 2013-04-16 |
![]() |
[795e61] added license |
README.md | 2013-08-07 |
![]() |
[e1defb] Update README.md |
get_pulse.py | 2013-08-13 |
![]() |
[3a7dc7] misc fixes for master branch |
get_pulse_ipcam.py | 2013-05-04 |
![]() |
[6b3e69] Update get_pulse_ipcam.py |
make_design_graph.py | 2013-04-16 |
![]() |
[b1a6d5] Update make_design_graph.py |
test_webcam.py | 2013-04-16 |
![]() |
[d63913] bugfixes for cv2.polylines and cv2.movewindow e... |
win_pythonxy.md | 2013-06-12 |
![]() |
[18f2dc] Update win_pythonxy.md |
A python code that detects the heart-rate of an individual using a common webcam or network IP camera.
Tested on OSX 10.8 (Mountain Lion), Ubuntu 13.04 (Ringtail), and Windows 7 & 8.
Inspired by reviewing recent work on Eulerian Video Magnification,
with motivation to implement something visually comparable (though not necessarily identical in formulation) to their
pulse detection examples using Python and OpenCV (see https://github.com/brycedrennan/eulerian-magnification for a
more general take on the offline post-processing methodology).
This goal is comparable to those of a few previous efforts in this area
(such as https://github.com/mossblaser/HeartMonitor).
This code was developed at NASA Glenn Research Center in
support of OpenMDAO, under the Aeronautical Sciences Project in NASA's
Fundamental Aeronautics Program, as well as the Crew State Monitoring Element
of the Vehicle Systems Safety Technologies Project, in NASA’s
Aviation Safety Program.
A list of other open-source NASA codes can be found at code.nasa.gov.
This application uses OpenCV to find the location of the user's face, then isolate the forehead region. Data is collected
from this location over time to estimate the user's heart rate. This is done by measuring average optical
intensity in the forehead location, in the subimage's green channel alone (a better color mixing ratio may exist, but the
blue channel tends to be very noisy). Physiological data can be estimated this way thanks to the optical absorption
characteristics of (oxy-) haemoglobin (see http://www.opticsinfobase.org/oe/abstract.cfm?uri=oe-16-26-21434).
With good lighting and minimal noise due to motion, a stable heartbeat should be
isolated in about 15 seconds. Other physiological waveforms (such as
Mayer waves) should also be visible in the raw data stream.
Once the user's heart rate has been estimated, real-time phase variation associated with this
frequency is also computed. This allows for the heartbeat to be exaggerated in the post-process frame rendering,
causing the highlighted forehead location to pulse in sync with the user's own heartbeat.
Support for detection on multiple simultaneous individuals in a single camera's
image stream is definitely possible, but at the moment only the information from one face
is extracted for analysis.
The overall dataflow/execution order for the real-time signal processing looks like:
This signal processing design is implemented in the openMDAO assembly object defined in
lib/processors.py.
The definition of each component block used can be found in the source
files lib/imageProcess.py, lib/signalProcess.py, and
lib/sliceops.py. The @bin
and @bout
blocks in the above graph denote assembly-level input and
output.
OpenCV is a powerful open-source computer vision library, with a convenient
numpy-compatible interface in the cv2 bindings.
OpenMDAO is an open-source engineering framework that serves as a convenient
environment to containerize the required real-time analysis, and
allow for that analysis to be easily tweaked to specification and compared with alternative designs.
Upon installation, OpenMDAO is bootstrapped into its own Python
virtualenv, which must be activated before use (see the Quickstart section below). OpenMDAO requires python 2.6+, numpy, scipy, and matplotlib
(see http://openmdao.org/docs/getting-started/requirements.html)
Running Windows, and completely new to Python? Full instructions for getting started with all requirements needed to
run this code are available here
. OpenMDAO/bin/activate
Or on Windows:
OpenMDAO\Scripts\activate
python get_pulse.py
url
, user
, and password
strings on line 134 of get_pulse_ipcam.py
, then run:python get_pulse_ipcam.py
This was tested on a Wowwee Rovio.
test_webcam.py
in the same directory to check if your openCV installation and webcam can be made to workdata_spike_limit
on line 31 of get_pulse.py.