Android-based implementation of Eulerian Video Magnification for vital signs monitoring
Full text
FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO Android-based implementation of Eulerian Video Magnification for vital signs monitoring Pedro Boloto Chambino Mestrado Integrado em Engenharia Informática e Computação Supervisor: Prof. Luís Teixeira Supervisor at Fraunhofer Portugal: Luís Rosado July 18, 2013
Android-based implementation of Eulerian Video Magnification for vital signs monitoring Pedro Boloto Chambino Mestrado Integrado em Engenharia Informática e Computação Approved in oral examination by the committee: Chair: Prof. Jorge Alves da Silva External Examiner: Prof. João Miguel da Costa Magalhães Supervisor: Prof. Luís Filipe Pinto de Almeida Teixeira July 18, 2013
Abstract Eulerian Video Magnification is a recently presented method capable of revealing temporal variations in videos that are impossible to see with the naked eye. Using this method, it is possible to visualize the flow of blood as it fills the face. From its result, a person’s heart rate is possible to be extracted. This research work was developed at Fraunhofer Portugal and its goal is to test the feasibility of the implementation of the Eulerian Video Magnification method on smartphones by developing an Android application for monitoring vital signs based on the Eulerian Video Magnification method. There has been some successful effort on the assessment of vital signs, such as, heart rate, and breathing rate, in a contact-free way using a webcamera and even a smartphone. However, since the Eulerian Video Magnification method was recently proposed, its implementation has not been tested in smartphones yet.Thus, the Eulerian Video Magnification method performance for color amplification was optimized in order to execute on an Android device at a reasonable speed. The Android application implemented includes features, such as, detection of a person’s cardiac pulse, dealing with artifacts’ motion, and real-time display of the magnified blood flow. Then, the application measurements were evaluated through tests with several individuals and compared to the ones detected by the ViTrox application and to the readings of a sphygmomanometer. i
ii
Contents 1 Introduction 1 1.1 Context ....................................... 1 1.2 Motivation...................................... 2 1.3 Objectives...................................... 2 1.4 Contributions .................................... 3 1.5 Outline ....................................... 3 2 State of the art 5 2.1 Photo-plethysmography............................... 5 2.2 Signalpost-processing ............................... 6 2.2.1 Independent Component Analysis . . . . . . . . . . . . . . . . . . . . . 6 2.2.2 Eulerian Video Magnification . . . . . . . . . . . . . . . . . . . . . . . 7 2.2.3 Detrending ................................. 9 2.3 Heartrateestimation ................................ 10 2.3.1 Powerspectrum............................... 10 2.3.2 Pulsewavedetection............................ 11 2.4 Technologies .................................... 12 2.4.1 AndroidSDK................................ 12 2.4.2 OpenCV – Computer Vision Library . . . . . . . . . . . . . . . . . . . . 13 2.5 Summary ...................................... 13 3 Pulse: vital signs monitoring application 15 3.1 Problemdescription................................. 15 3.1.1 Android-based implementation of Eulerian Video Magnification . . . . . 15 3.1.2 Vital signs monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.2 Implementationdetails ............................... 16 3.2.1 Overview.................................. 17 3.2.2 Eulerian Video Magnification implementations . . . . . . . . . . . . . . 17 3.2.3 Facedetection ............................... 21 3.2.4 Signalvalidation .............................. 22 3.2.5 Heart rate estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.2.6 Androidintegration............................. 23 3.3 Pulse: Android application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.4 Summary ...................................... 25 4 Results 27 4.1 Performance..................................... 27 4.2 Heart rate estimation comparison . . . . . . . . . . . . . . . . . . . . . . . . . . 31 iii
CONTENTS 4.3 Summary ...................................... 32 5 Conclusions 35 5.1 Objectivesatisfaction................................ 35 5.2 Futurework..................................... 36 A Performance metrics 39 References 51 iv
List of Figures 2.1 Overview of the Eulerian Video Magnification method. (source: [WRS+12]) . . 7 2.2 Examples of temporal filters. (source: [WRS+12]) ................ 8 2.3 Emphasis of face color changes using the Eulerian Video Magnification method. (source: [WRS+12]) ................................ 9 2.4 Original RR series and fitted trends (above) and detrended series without magnitude distortion (below). (source: [TRaK02]) . . . . . . . . . . . . . . . . . . . . 10 3.1 Overview of the implemented algorithm to obtain the heart rate of a person from a webcam or video using the Eulerian Video Magnification method. . . . . . . . 16 3.2 Overview of the Eulerian Video Magnification method steps. . . . . . . . . . . . 18 3.3 Overview of image deconstruction and reconstruction for building a Laplacian pyramid........................................ 20 3.4 Overview of the interaction between the implemented Android application and library. ....................................... 24 3.5 User interface of the implemented Android application, Pulse. . . . . . . . . . . 24 4.1 A summary of the performance optimizations milestones. The first legend item is the implementation of the overall algorithm described in section 3.2.1. The second is the implementation of the Eulerian Video Magnification described in section 3.2.2.4. The rest are operations that belong to these two functions that were optimized. The transition from 20-Mar to 26-Mar shows the improvement by replacing the pyramid construction and deconstruction operations by single resize operations and simpler interpolation methods for the resize operations. The transition to 3-Apr is the restriction of the face detection operation to once a second instead of every frame. And the final transition, 23-May, is the removal of the last two resize operations by taking advantage of the improvement from 20-Mar to 26-Mar which removes the requirement of the input matrix for the Eulerian Video Magnification method to be always of the same size. . . . . . . . . . . . . . . . 30 4.2 Bland-Altman plots demonstrating the agreement between the heart rate measurements obtained from a sphygmomanometer and an Android application: either Pulse, (a), (c), (d), which is the developed application, or the ViTrox application, (b). ......................................... 34 v
Introduction 1.2 Motivation There has been some successful effort on the assessment of vital signs, such as, heart rate, and breathing rate, in a contact-free way using a webcamera [WRS+12, PMP10, PMP11], and even a smartphone [Tec13, Phi13]. Other similar products, which require specialist hardware and are thus expensive, include laser Doppler [UT93], microwave Doppler radar [Gre97], and thermal imaging [GSMP07]. Since it is a cheaper method of assessing vital signs in a contact-free way than the above products, this research work has potential for advancing fields, such as, telemedicine,personal health-care, and ambient assisting living. Despite the existence of very similar products by Philips [Phi13] and ViTrox Technologies [Tec13] to the one proposed on this research work, none of these implement the Eulerian Video Magnification method. Due to being recently proposed, the Eulerian Video Magnification method implementation has not been tested in smartphones yet. 1.3 Objectives In this work, an Android application for monitoring vital signs based on the Eulerian Video Magnification method will be developed, which should include the following features: •heart rate detection and assessment based on the Eulerian Video Magnification method; •display real-time changes, such as, the magnified blood flow, obtained from the Eulerian Video Magnification method; •deal with artifacts’ motion, due to, person and/or smartphone movement. In order to accomplish that, the feasibility of the Eulerian Video Magnification method on smartphones has to be tested. It should be noted that a straightforward implementation of the Eulerian Video Magnification method is not possible, due to various reasons. First, the Eulerian Video Magnification method provides motion magnification along with color magnification which will introduce several problems with artifacts’ motion. Second, the requirement of implementing a real-time smartphone application will create performance issues which will have to be addressed and trade-offs will have to be considered. The application performance should then be evaluated through tests with several individuals and the assessed heart rate compared to the ones detected by another application [Tec13, Phi13], and to the measurement of an electronic sphygmomanometer. 2
Introduction 1.4 Contributions The work of this thesis contributes to the current state of the art by testing the feasibility of implementing a performance optimized version of the Eulerian Video Magnification method for color amplification in order to be capable of being used on a smartphone at a reasonable frame rate. In addition, it also tests the usage of such method in the assessment of a person’s heart rate using the smartphone’s camera. This shows that the method is ready to be used on mobile devices and that it can start being used in other kinds of applications. 1.5 Outline The rest of the document is structured as follows: Chapter 2 introduces the concepts necessary to understand the presented problem. In addition, it presents the existing related work, and a description of the main technologies used. Chapter 3 provides a detailed description of the problem addressed, defining its scope. And describes the implementation details of the work developed in order to create an Android application, named Pulse, for estimating a person’s heart rate based on the Eulerian Video Magnification method. Chapter 4 reports and analyses the results from the application performance and heart rate comparison. Chapter 5 finalizes this document by presenting the conclusions of this project, along with possible further developments and future work. 3
Introduction 4
Chapter 2 State of the art This chapter focus on the heart rate estimation from a person’s face captured through a simple webcam. Section 2.1 describes the concept that explains how the cardiac pulse is detected from a person’s face in a remote, contact-free way. Post-processing methods, which may be applied to the retrieved signal, are detailed on section 2.2. In order to estimate the heart rate, some techniques are also detailed on section 2.3. Finally, section 2.4 reviews the main technologies and tools used throughout this work. 2.1 Photo-plethysmography Photo-plethysmography (PPG) is the concept of measuring volumetric changes of an organ optically. Its most established use is in pulse oximeters. PPG is based on the principle that blood absorbs more light than surrounding tissue thus variations on blood volume affect light reflectance [VSN08]. The use of dedicated light sources and infra-red wavelengths, and contact probes has been the norm [UT93, Gre97, GSMP07]. However, recently, remote, non-contact PPG imaging has been explored [WMVdS05, HZCS08]. The method used on the article [VSN08] captures the pixel values (red, green, and blue channels) of the facial area of a previously recorded video where volunteers were asked to minimize movements. The pixel values within a region of interest (ROI) were then averaged for each frame. This spatial averaging was found to significantly increase signal-to-noise ratio. The heart rate estimation was then calculated by applying the Fast Fourier transform and the power spectrum as explained on section 2.3.1. The authors of [VSN08] demonstrate that the green channel features a stronger cardiac signal as compared to the red and blue channels. This is a strong evidence that the signal is due to 5
State of the art variations in the blood volume, because hemoglobin absorbs green light better than red and blue light. 2.2 Signal post-processing After obtaining the raw pixel values (red, green, and blue channels), a combination of the following methods may be used to extract and improve the reflected plethysmography signal. However, each method introduces complexity and expensive computation. 2.2.1 Independent Component Analysis Independent Component Analysis is a special case of blind source separation and is a technique for uncovering independent signals from a set of observations that are composed of linear mixtures of the underlying sources [Com94]. In this case, the underlying source signal of interest is the cardiac pulse that propagates throughout the body, which modifies the path length of the incident ambient light due to volumetric changes in the facial blood vessels during the cardiac cycle, such that subsequent changes in amount of reflected light indicate the timing of cardiovascular events. By recording a video of the facial region, the red, green, and blue (RGB) color sensors pick up a mixture of the reflected plethysmographic signal along with other sources of fluctuations in light due to artifacts. Each color sensor records a mixture of the original source signals with slightly different weights. These observed signals from the red, green and blue color sensors are denoted by x1(t),x2(t)and x3(t)respectively, which are amplitudes of the recorded signals at time point t. In conventional Independent Component Analysis model the number of recoverable sources cannot exceed the number of observations, thus three underlying source signals were assumed, represented by s1(t),s2(t)and s3(t). The Independent Component Analysis model assumes that the observed signals are linear mixtures of the sources, i.e. xi(t) = ∑3 j=1aijsj(t)for each i=1,2,3. This can be represented compactly by the mixing equation x(t) = As(t)(2.1) where the column vectors x(t) = [x1(t),x2(t),x3(t)]T,s(t) = [s1(t),s2(t),s3(t)]Tand the square 3×3 matrix Acontains the mixture coefficients aij. The aim of Independent Component Analysis model is to find a separating or demixing matrix Wthat is an approximation of the inverse of the original mixing matrix Awhose output ˆs(t) = Wx(t)(2.2) is an estimate of the vector s(t)containing the underlying source signals. To uncover the independent sources, W must maximize the non-Gaussianity of each source. In practice, iterative methods are used to maximize or minimize a given cost function that measures non- Gaussianity [PMP10, PMP11]. 6
State of the art Spatial Decomposition Input video Temporal Processing (pixel-wise) ɲ1 ɲ2 ɲnͲ1 Reconstruction Eulerian video magnification Output video ɲn Ȉ Ȉ Ȉ Ȉ time y time y ٔ Figure 2: Overview of the Eulerian video magnification framework. The system first decomposes the input video sequence into different spatial frequency bands, and applies the same temporal filter to all bands. The filtered spatial bands are then amplified by a given factor ↵, added back to the original signal, and collapsed to generate the output video. The choice of temporal filter and amplification factors can be tuned to support different applications. For example, we use the system to reveal unseen motions of a Digital SLR camera, caused by the flipping mirror during a photo burst (camera; full sequences are available in the supplemental video). on accurate motion estimation, which is computationally expensive and difficult to make artifact-free, especially at regions of occlusion boundaries and complicated motions. Moreover, Liu et al. [2005] have shown that additional techniques, including motion segmentation and image in-painting, are required to produce good quality synthesis. This increases the complexity of the algorithm further. In contrast, we are inspired by the Eulerian perspective, where properties of a voxel of fluid, such as pressure and velocity, evolve over time. In our case, we study and amplify the variation of pixel values over time, in a spatially-multiscale manner. In our Eulerian approach to motion magnification, we do not explicitly estimate motion, but rather exaggerate motion by amplifying temporal color changes at fixed positions. We rely on the same differential approximations that form the basis of optical flow algorithms [Lucas and Kanade 1981; Horn and Schunck 1981]. Temporal processing has been used previously to extract invisible signals [Poh et al. 2010] and to smooth motions [Fuchs et al. 2010]. For example, Poh et al. [2010] extract a heart rate from a video of a face based on the temporal variation of the skin color, which is normally invisible to the human eye. They focus on extracting a single number, whereas we use localized spatial pooling and bandpass filtering to extract and reveal visually the signal corresponding to the pulse. This primal domain analysis allows us to amplify and visualize the pulse signal at each location on the face. This has important potential monitoring and diagnostic applications to medicine, where, for example, the asymmetry in facial blood flow can be a symptom of arterial problems. Fuchs et al. [2010] use per-pixel temporal filters to dampen temporal aliasing of motion in videos. They also discuss the high-pass filtering of motion, but mostly for non-photorealistic effects and for large motions (Figure 11 in their paper). In contrast, our method strives to make imperceptible motions visible using a multiscale approach. We analyze our method theoretically and show that it applies only for small motions. In this paper, we make several contributions. First, we demonstrate that nearly invisible changes in a dynamic environment can be revealed through Eulerian spatio-temporal processing of standard monocular video sequences. Moreover, for a range of amplification values that is suitable for various applications, explicit motion estimation is not required to amplify motion in natural videos. Our approach is robust and runs in real time. Second, we provide an analysis of the link between temporal filtering and spatial motion and show that our method is best suited to small displacements and lower spatial frequencies. Third, we present a single framework that can be used to amplify both spatial motion and purely temporal changes, e.g., the heart pulse, and can be adjusted to amplify particular temporal frequencies—a feature which is not supported by Lagrangian methods. Finally, we analytically and empirically compare Eulerian and Lagrangian motion magnification approaches under different noisy conditions. To demonstrate our approach, we present several examples where our method makes subtle variations in a scene visible. 2 Space-time video processing Our approach combines spatial and temporal processing to emphasize subtle temporal changes in a video. The process is illustrated in Figure 2. We first decompose the video sequence into different spatial frequency bands. These bands might be magnified differently because (a) they might exhibit different signal-to-noise ratios or (b) they might contain spatial frequencies for which the linear approximation used in our motion magnification does not hold (Sect. 3). In the latter case, we reduce the amplification for these bands to suppress artifacts. When the goal of spatial processing is simply to increase temporal signal-to-noise ratio by pooling multiple pixels, we spatially low-pass filter the frames of the video and downsample them for computational efficiency. In the general case, however, we compute a full Laplacian pyramid [Burt and Adelson 1983]. We then perform temporal processing on each spatial band. We consider the time series corresponding to the value of a pixel in a frequency band and apply a bandpass filter to extract the frequency bands of interest. For example, we might select frequencies within 0.4-4Hz, corresponding to 24-240 beats per minute, if we wish to magnify a pulse. If we are able to extract the pulse rate, we can use a narrow band around that value. The temporal processing is uniform for all spatial levels, and for all pixels within each level. We then multiply the extracted bandpassed signal by a magnification factor ↵. This factor can be specified by the user, and may be attenuated automatically according to guidelines in Sect. 3.2. Possible temporal filters are discussed in Sect. 4. Next, we add the magnified signal to the original and collapse the spatial pyramid to obtain Figure 2.1: Overview of the Eulerian Video Magnification method. (source: [WRS+12]) 2.2.2 Eulerian Video Magnification In contrast to the Independent Component Analysis model that focuses on extracting a single number, the Eulerian Video Magnification uses localized spatial pooling and temporal filtering to extract and reveal visually the signal corresponding to the cardiac pulse. This allows for amplification and visualization of the heart rate signal at each location on the face. This creates potential for monitoring and diagnostic applications to medicine, i.e. the asymmetry in facial blood flow can be a symptom of arterial problems. Besides color amplification, the Eulerian Video Magnification method is also able to reveal low-amplitude motion which may be hard or impossible for humans to see. Previous attempts to unveil imperceptible motions in videos have been made, such as, [LTF+05] which follows aLagrangian perspective, as in fluid dynamics where the trajectory of particles is tracked over time. By relying on accurate motion estimation and additional techniques to produce good quality synthesis, such as, motion segmentation and image in-painting, the algorithm complexity and computation is expensive and difficult. On the contrary, the Eulerian Video Magnification method is inspired by the Eulerian perspective, where properties of a voxel of fluid, such as pressure and velocity, evolve over time. The approach of this method to motion magnification is the exaggeration of motion by amplifying temporal color changes at fixed positions, instead of, explicit estimation of motion. This method approach, illustrated in figure 2.1, combines spatial and temporal processing to emphasize subtle temporal changes in a video. First, the video sequence is decomposed into different spatial frequency bands. Because they may exhibit different signal-to-noise ratios, they may be magnified differently. In the general case, the full Laplacian pyramid [BA83] may be computed. Then, temporal processing is performed on each spatial band. The temporal processing is uniform for all spatial bands, and for all pixels within each band. After that, the extracted bandpass signal is magnified by a factor of α, which can be specified by the user, and may be attenuated automatically. Finally, the magnified signal is added to the original image and the spatial pyramid collapsed to obtain the final output. 7
State of the art Figure 2.2: Examples of temporal filters. (source: [WRS+12]) 2.2.2.1 Spatial filtering As mention before, the work of [WRS+12] computes the full Laplacian pyramid [BA83] as a general case for spatial filtering. Each layer of the pyramid may be magnified differently because it may exhibit different signal-to-noise ratios, or contain spatial frequencies for which the linear approximation used in motion magnification does not hold [WRS+12, Section 3]. Spatial filtering may also be used to significantly increase signal-to-noise ratio, as previously mention on section 2.1 and demonstrated on the work of [VSN08] and [WRS+12]. Subtle signals, such as, a person’s heart rate from a video of its face, may be enhanced this way. For this purpose the work of [WRS+12] computes a layer of the Gaussian pyramid which may be obtained by successively scaling down the image by calculating the Gaussian average for each pixel. However, for the signal of interest to be revealed, the spatial filter applied must be large enough. Section 5 of [WRS+12] provides an equation to estimate the size for a spatial filter needed to reveal a signal at a certain noise power level: S(λ) = S(r) = σ02=kσ2 r2(2.3) where S(λ)represents the signal over spatial frequencies, and since the wavelength, λ, cutoff of a spatial filter is proportional to its radius, r, the signal may be represented as S(r). The noise power, σ2, can be estimated using to the technique of [LFSK06]. Finally, because the filtered noise power level, σ02, is inversely proportional to r2, it is possible to solve the equation for r, where kis a constant that depends on the shape of the low pass filter. 2.2.2.2 Temporal filtering Temporal filtering is used to extract the motions or signals to be amplified. Thus, the filter choice is application dependent. For motion magnification, a broad bandpass filter, such as, the butterworth filter, is preferred. A narrow bandpass filter produces a more noise-free result for color amplification of blood flow. An ideal bandpass filter is used on [WRS+12] due to its sharp cutoff frequencies. Alternatively, for a real-time implementation low-order IIR filters can be useful for both: color amplification and motion magnification. These filters are illustrated on 2.2. 8
State of the art Eulerian Video Magnification for Revealing Subtle Changes in the World Hao-Yu Wu1Michael Rubinstein1Eugene Shih2John Guttag1Fr´ edo Durand1William Freeman1 1MIT CSAIL 2Quanta Research Cambridge, Inc. (a) Input (b) Magnified (c) Spatiotemporal YT slices time y time y Figure 1: An example of using our Eulerian Video Magnification framework for visualizing the human pulse. (a) Four frames from the original video sequence (face). (b) The same four frames with the subject’s pulse signal amplified. (c) A vertical scan line from the input (top) and output (bottom) videos plotted over time shows how our method amplifies the periodic color variation. In the input sequence the signal is imperceptible, but in the magnified sequence the variation is clear. The complete sequence is available in the supplemental video. Abstract Our goal is to reveal temporal variations in videos that are difficult or impossible to see with the naked eye and display them in an indicative manner. Our method, which we call Eulerian Video Magnification, takes a standard video sequence as input, and applies spatial decomposition, followed by temporal filtering to the frames. The resulting signal is then amplified to reveal hidden information. Using our method, we are able to visualize the flow of blood as it fills the face and also to amplify and reveal small motions. Our technique can run in real time to show phenomena occurring at temporal frequencies selected by the user. CR Categories: I.4.7 [Image Processing and Computer Vision]: Scene Analysis—Time-varying Imagery; Keywords: video-based rendering, spatio-temporal analysis, Eulerian motion, motion magnification Links: DL PDF WEB 1 Introduction The human visual system has limited spatio-temporal sensitivity, but many signals that fall below this capacity can be informative. For example, human skin color varies slightly with blood circulation. This variation, while invisible to the naked eye, can be exploited to extract pulse rate [Verkruysse et al. 2008; Poh et al. 2010; Philips 2011]. Similarly, motion with low spatial amplitude, while hard or impossible for humans to see, can be magnified to reveal interesting mechanical behavior [Liu et al. 2005]. The success of these tools motivates the development of new techniques to reveal invisible signals in videos. In this paper, we show that a combination of spatial and temporal processing of videos can amplify subtle variations that reveal important aspects of the world around us. Our basic approach is to consider the time series of color values at any spatial location (pixel) and amplify variation in a given temporal frequency band of interest. For example, in Figure 1 we automatically select, and then amplify, a band of temporal frequencies that includes plausible human heart rates. The amplification reveals the variation of redness as blood flows through the face. For this application, temporal filtering needs to be applied to lower spatial frequencies (spatial pooling) to allow such a subtle input signal to rise above the camera sensor and quantization noise. Our temporal filtering approach not only amplifies color variation, but can also reveal low-amplitude motion. For example, in the supplemental video, we show that we can enhance the subtle motions around the chest of a breathing baby. We provide a mathematical analysis that explains how temporal filtering interplays with spatial motion in videos. Our analysis relies on a linear approximation related to the brightness constancy assumption used in optical flow formulations. We also derive the conditions under which this approximation holds. This leads to a multiscale approach to magnify motion without feature tracking or motion estimation. Previous attempts have been made to unveil imperceptible motions in videos. [Liu et al. 2005] analyze and amplify subtle motions and visualize deformations that would otherwise be invisible. [Wang et al. 2006] propose using the Cartoon Animation Filter to create perceptually appealing motion exaggeration. These approaches follow a Lagrangian perspective, in reference to fluid dynamics where the trajectory of particles is tracked over time. As such, they rely Figure 2.3: Emphasis of face color changes using the Eulerian Video Magnification method. (source: [WRS+12]) 2.2.2.3 Emphasize color variations for human pulse The extraction of a person’s cardiac pulse using the Eulerian Video Magnification method was demonstrated in [WRS+12]. It was also presented that using the right configuration can help extract the desired signal. There are four steps to take when processing a video using the Eulerian Video Magnification method: 1. select a temporal bandpass filter; 2. select an amplification factor, α; 3. select a spatial frequency cutoff (specified by spatial wavelength, λc) beyond which an attenuated version of αis used; 4. select the form of the attenuation for α—- either force αto zero for all λ<λc, or linearly scale αdown to zero. For human pulse color variation, two temporal filters may be used, first selecting frequencies within 0.4-4Hz, corresponding to 24-240 beats per minute (bpm), then a narrow band of 0.83- 1Hz (50-60 bpm) may be used, if the extraction of the pulse rate was successful. To emphasize the color change as much as possible, a large amplification factor, α≈100, and spatial frequency cutoff, λc≈1000, is applied. With an attenuation of αto zero for spatial wavelengths below λc. The resulting output can be seen in figure 2.3. 2.2.3 Detrending Detrending is a method of removing very large ultralow-frequency trends an input signal without any magnitude distortion, acting as an high-pass filter. 9
State of the art 3 a) Original and detrended RR series 0.7 0.9 1.1 0 100 200 −0.2 0 0.2 0 100 200 0 100 200 0 100 200 Time (s) RRI (s) b) Time domain analysis SDNN RMSSD pNN50 SDNN RMSSD pNN50 SDNN RMSSD pNN50 SDNN RMSSD pNN50 (ms) (ms) (%) (ms) (ms) (%) (ms) (ms) (%) (ms) (ms) (%) Original 63.62 72.40 53.00 60.96 37.34 16.80 53.01 62.72 53.95 52.93 37.48 17.29 Detrended 55.54 72.10 52.07 41.42 36.98 15.98 49.15 62.51 54.42 41.90 37.21 16.92 c) Frequency domain analysis 0 0.01 0.02 0.03 0 0.25 0.5 0 0.01 0.02 0.03 0 0.25 0.5 0 0.25 0.5 0 0.25 0.5 Frequency (Hz) PSD (s2/Hz) Fig. 2. The e↵ect of the detrending method on time and frequency domain analysis. a) Original RR series and fitted trends (above) and detrended RR series (below) for four di↵erent data segments. The duration of each data segment is 200 seconds and they were obtained from di↵erent subjects. b) The e↵ect of the detrending procedure on three time domain parameters (SDNN, RMSSD and pNN50). c) PSD estimates for original (thin line) and detrended (bold line) RR series with Welch’s periodogram method (above) and by using a 16’th order AR model (below). ponent. Each spectrum is however limited to 0.035 s2/Hz to enable the comparison of the spectrums before and after detrending. For Welch’s method the VLF components are properly removed while the higher frequencies are not significantly altered by the detrending. But when AR models of relatively low orders are used, which is usually desirable in HRV analysis in order to enable a distinct division of the spectrum into VLF, LF and HF components, the e↵ect of detrending is remarkable. In each original AR spectrum the peak around 0.1 Hz is spuriously covered by the strong VLF component. However in the AR spectrums obtained after detrending the component near 0.1 Hz is more realistic when compared to the spectrums obtained by Welch’s method. IV. Discussion We have presented an advanced detrending method with application to HRV analysis. The method is based on smoothness priors formulation. The main advantage of the method, compared to methods presented in [7], [5], is its simplicity. The frequency response of the method is adjusted with a single parameter. This smoothing parameter should be selected in such a way that the spectral components of interest are not significantly a↵ected by the detrending. Another advantage of the presented method is that the filtering e↵ect is attenuated in the beginning and the end of the data and thus the distortion of data end points is avoided. The e↵ect of detrending on time and frequency domain analysis of HRV was demonstrated. In time domain most e↵ect is focused on SDNN, which describes the amount of overall variance of RR series. Instead only little e↵ect is focused on RMSSD and pNN50 which both describe the di↵erences in successive RR intervals. In frequency domain the low frequency trend components increase the power of VLF component. Thus, when using relatively low order AR models in spectrum estimation detrending is especially recommended, since the strong VLF component distorts other components, especially the LF component, of the spectrum. The presented detrending method can be applied to e.g. respiratory sinus arrhythmia (RSA) quantification. RSA component is separated from other frequency components of HRV by adjusting the smoothing parameter properly. For other purposes of HRV analysis one should make sure that the detrending does not lose any useful information from the lower frequency components. Finally, it should be emphasized that the presented detrending method is not restricted to HRV analysis only, but can be applied as well to other biomedical signals e.g. for detrending of EEG signals in quantitative EEG analysis. Figure 2.4: Original RR series and fitted trends (above) and detrended series without magnitude distortion (below). (source: [TRaK02]) The main advantage of the method presented on the work of [TRaK02], compared to methods presented in [LOCS95] and [PB90], is its simplicity. The method consists of separating the input signal, z, into two components, as z=zstat +ztrend, where zstat is the nearly stationary component, and ztrend is the low frequency aperiodic trend component. An estimation of the nearly stationary component, ˆzstat, can be obtained using the equation below. The detailed derivation of the equation can be found in [TRaK02]. ˆzstat = (I−(I+λ2DT 2D2)−1)z(2.4) where Iis the identity matrix, D2is the discrete approximation of the second order, and λis the regularization parameter. Figure 2.4 presents an example of what this method is able to achieve. The example, taken from the work of [TRaK02], uses real RR series and the effect of the method on time and frequency domain analysis of heart rate variability is demonstrated not to lose any useful information. 2.3 Heart rate estimation In order to convert the extracted plethysmographic signal into the number of beats per minute (bpm), further processing must be done. Below two methods capable of achieving this goal are highlighted. 2.3.1 Power spectrum Fourier transform is a mathematical transform capable of converting a function of time, f(t), into a new function representing the frequency domain of the original function. To calculate the power spectrum, the resulting function from the Fourier transform is then multiplied by itself. Since the values are captured from a video, sequence of frames, the function of time is actually discrete, with a frequency rate equal to the video frame rate, FPS. 10
State of the art The index,i, corresponding to the maximum of the power spectrum can then be converted into a frequency value, F, using the equation: F=i∗FPS 2N(2.5) where Nis the size of the signal extracted. Fcan then be multiplied by 60 to convert it to beats per minute, and have an estimation of the heart rate from the extracted signal. 2.3.2 Pulse wave detection In [NI10], an automated algorithm for fast pulse wave detection is presented. The algorithm is capable of obtaining an estimative of the heart rate from PPG signal, as an alternative to the power spectrum described above. Moreover, it also introduces validation to the waveform detection by verifying its shape and timing. Below a simplified description of the algorithm is presented. A more detailed description can be found in [NI10]. 1. Identification of possible peaks and foots of individual pulses (a) Maximum (MAX) The signal is divided into consecutive 200ms time intervals and for every segment the absolute maximum is determined. Some of these maximums are rejected: if they fall below a predetermined amplitude threshold; or if the distance between two maximums is less than or equal to 200ms, then the lower maximum is rejected. (b) Minimum (MIN) The absolute minimum is determined between every two adjacent maximums. A minimum is rejected, if it is above a predetermined amplitude threshold. When a minimum is rejected, the lower-amplitude maximum of the two maximum adjacent to the rejected minimum is discarded too. 2. Examination and verification of the rising edges (a) Validation of a single rising edge If a rising edge is rejected, its maximum and minimum are rejected. A rising edge is rejected, if its amplitude (AMPL =MAX −MIN) is lower than amplitude threshold; or its duration is lower than a threshold that depends on the sampling rate; or its amplitude does not increase smoothly. (b) Estimation of the similarity of a rising edge to preceding and following rising edges accepted as valid Two rising edges are considered similar, if the amplitude of the lower-amplitude rising edge is greater than 50% of the amplitude of the higher-amplitude rising edge; and if the maximum of the lower-amplitude rising edge is between ±60% of the maximum of the higher-amplitude rising edge; and if the minimum of the lower-amplitude rising edge is between ±60% of the minimum of the higher-amplitude rising edge; and if the 11
Pulse: vital signs monitoring application Figure 3.2: Overview of the Eulerian Video Magnification method steps. The purpose of implementing multiple variants of the method was to study how the method worked and select which spatial and temporal filters would better fit the application goal: amplify color variation in real-time. Figure 3.2 shows generic steps of the method which will be detailed on each of the following sections. The final step, add to original frame, however, remains the same in all implementations. Which is when the magnified values are added back to the original frame in order to obtain the processed frame. 3.2.2.1 EvmGdownIdeal This was the first implementation, thus, its goal was to understand how the method worked, and match the implementation provided, in MATLAB, by [WRS+12]. In addition, real-time support was implemented by using a sliding window of 30 frames. Resize down This step applies a spatial filter by calculating a level of the Gaussian pyramid. This is achieved by looping to the desired level where the input to the next loop is the result from the previous loop, starting with the original frame. A Gaussian pyramid level is calculated by, first, convolving the input frame with the kernel, K: K=1 256 1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 4 16 24 16 4 1 4 6 4 1 (3.1) and then, downsampling the frame by rejecting even rows and columns. 18
Pulse: vital signs monitoring application Temporal filter An ideal bandpass filter was used to remove any amplification of undesired frequency from the color variation of each pixel. To construct this ideal filter, the Fourier transform was calculated for each pixel over the sliding window of 30 frames. Then, frequencies below 45 and above 240 where set to zero, and the frame was rebuilt using the inverse Fourier transform. Amplification In this step, the result of the temporal filter is multiplied by an αvalue, which results in the magnification of the color variation selected by the temporal filter. Resize up This step performs the inverse operation of the resize down step, where it upsamples the frame by inserting even rows and columns with zeros, and then, convolves the input frame with the same kernel multiplied by 4. However, when the original frame is not multiple of two, an additional resize operation as to be done in order for the upsampled frame to match the original frame’s size. 3.2.2.2 EvmGdownIIR This implementation is very similar to the one above, but uses a different temporal filter which does not require a sliding window of frames to support real-time results. The filter used was an IIR bandpass filter, which was constructed from the subtraction of two first-order lowpass IIR filters. Each lowpass filter is computed as follows: Ln=Ln−1∗(1−ω)+ ω∗M(3.2) where Mis the current frame, Lis the lowpass filter accumulator for each frame, and ωis the cutoff frequency percentage. The IIR temporal bandpass filter demonstrated similar results to the ideal temporal filter used on the first implementation, without the need for persisting a sliding window of frames, which simplifies the solution and reduces the computational power required by the device. 3.2.2.3 EvmLpyrIIR Using the same IIR temporal filter as above, this implementation uses a different spatial filter, which, instead of, computing a level of the Gaussian pyramid, it constructs the full Laplacian pyramid and then applies the temporal filter to each of its bands and each band is amplified differently. Resize down Figure 3.3 shows the steps to decompose and reconstruct an image for the purpose of building a Laplacian pyramid. The original image must be decomposed into two images, blurred 19
Pulse: vital signs monitoring application Figure 3.3: Overview of image deconstruction and reconstruction for building a Laplacian pyramid. and fine, by applying any type of spatial lowpass filter and scaling the image down or up by 2. In this case, a Gaussian filter was applied as described on steps resize down and resize up of the first implementation. Further levels of the pyramid can be computed by decomposing the blurred image in the same manner. Temporal filter The temporal filter used is the IIR bandpass filter, as described above for the previous implementation, only this time it is applied to each level of the pyramid. Amplification The amplification method in this implementation is more complex than the one previously used. It is based on the implementation provided by [WRS+12]. It uses a different αvalue for each band of spatial frequencies, which corresponds to the Laplacian pyramid levels. The magnification value, α, follows the equation: (1+α)δ(t)<λ 8(3.3) where δ(t)represents the displacement function and λthe spatial wavelength. Further details about this equation may be found on [WRS+12, Section 3.2]. Resize up This step reconstructs the original image by iteratively reconstructing each blurred image until the now processed original image is reached. This implementation demonstrated that by constructing a Laplacian pyramid for the spatial filter finer motion detail would be revealed, whereas the color variation, the property to be analyzed, was less evident. 20
Pulse: vital signs monitoring application 3.2.2.4 Performance optimized EvmGdownIIR Because the OpenCV Java binding was not complete at the time, the Java desktop implementations were not executing fast enough for real-time processing. Thus, a C/C++ implementation of the method that demonstrated better color variation was developed. In addition, after studying the performance of the application, detailed on section 4.1, the resize operations proved to be computationally expensive. Therefore, the resize down and resize up steps were modified to faster resize operations that did not alter the resulting image. Resize down This step was changed to a single resize operation using the OpenCV interpolation method named area, which produces a similar result to the one provided by using a Gaussian filter and downsampling the image. However, instead of, iteratively downsampling the frame multiple times, it is now a single resize to a predefined size. Resize up This step was also modified to a single resize operation using the linear interpolation method, which produces a similar result to the one used previously where the image was upsampled iteratively using a Gaussian filter. 3.2.3 Face detection The face detection step uses the OpenCV object detector initially proposed on [VJ01] and improved on [LM02]. Which has been previously trained to detect faces. Because object detectors are computationally expensive, in order to improve performance, a minimum size for the face detector was set to 40% of the frame width and height. In addition, since it was expected for the person to remain still during the reading, the face detector was set to execute only once a second. Face tracking is simply done by matching the previous and newly detected faces to the closest one. •If there are less newly detected faces than the previously detected ones, then match each new face to the nearest older face. Any older face that is not matched with a newly detected face is marked for deletion. However, it is only deleted if it fails to find a match on the next time the face detector executes. This measure allows the face detector to miss a detection of a face one time. •Otherwise, if the number of newly detected faces is equal or more than the older faces, then match each older face to the nearest newly detected face. Any newly detected face that is not matched with an older face is then marked as a new face. Another performance boost was achieved by only magnifying each face rectangle instead of the whole frame. Because of this, the face rectangle must remain as still as possible, in order to introduce as few artifacts and noise to the Eulerian Video Magnification method. To achieve 21
Pulse: vital signs monitoring application this, the position and size of the face’s rectangle that is fed into the Eulerian Video Magnification method is interpolated between the previous and newly detected faces, if the distance between the two, d, is less than one third of the previous face’s rectangle width, w: d<w 3(3.4) And, the interpolation percentage, r, used is the ratio between these values: r=3d w(3.5) 3.2.4 Signal validation The signal validation has two phases. First, the raw signal, obtained by averaging the mean value of the green channel of a rectangle’s face, is checked for noise, on step signal noise in figure 3.1. Then, on step validate signal, the shape and timing of the detrended and normalized signal is verified. The raw signal noise is simply verified if the signal standard deviation is higher than 50% of the α, amplification factor. Then, each of the following operations are applied to the raw signal: 1. detrend, as in [TRaK02], also shortly described on section 2.2.3; 2. normalization, the normalized signal, S0, is obtained from the detrended signal, S, by subtracting the mean of the signal, ¯ S, and dividing it by the signal standard deviation, σ: S0=S−¯ S σ(3.6) 3. mean filter, is done by convolving the signal 3 times with the kernel, K: K=1 5∗5 11111 11111 11111 11111 11111 (3.7) Finally, the shape and timing of signal is validated by a simplification of the fast pulse wave detection algorithm [NI10]. It identifies possible signal peaks by dividing the signal into consecutive 200ms time intervals and finding the absolute maximum. Some of these maximums are rejected: if they are a boundary value of that segment; or if they fall below a threshold, which is 60% of the mean of the amplitude of the possible identified peaks so far; or if the distance between two maximums is less than or equal to 200ms, then the lower maximum is rejected. 22
Pulse: vital signs monitoring application The signal is said to be valid if: •it includes at least two peaks; •the peak count is between the valid human range, between 40 and 240 bpm; •the peaks’ amplitude standard deviation is less than 0.5; •the standard deviation of the time interval between peaks is less than 0.5; To prevent invalidating the signal if a peak is missed or miscounted, the signal is kept as valid for the next 30 frames. 3.2.5 Heart rate estimation Even though the simplification ofthe fast pulse wave detection algorithm presented on the previous section was capable of counting pulse wave peaks, it would frequently miscount at least by one peak. Thus, since the period analyzed was short, only 5 seconds at 20 frames per second, a miscounted peak would introduce a large error to the final value. In order to obtain the value of beats per minute from the pulse signal, the method presented on section 2.3.1 was used every time the signal was marked as valid. To prevent big fluctuations, the value was averaged over the values obtained from the power spectrum method every 1 second. 3.2.6 Android integration Due to performance, speed implementation, and easier testing, the algorithm’s library was implemented in C/C++. To integrate with the Android SDK, the framework Java Native Interface was used. Because each JNI call from the Android SDK to the Android NDK introduces performance overhead, the fewer calls made to the library, the faster the application executes. The Android application workflow and interaction with the Pulse library is illustrated on figure 3.4. The arrows that cross the modules’ borders represent JNI methods’ calls. As it is indicated, the whole algorithm is executed in one JNI call each frame in order to improve application performance. Three extra calls are made to obtain and display data to the user. 3.2.6.1 OpenCV for Android SDK The OpenCV library is supported in the Android platform by installing a separate Android application which deals with selecting the appropriate OpenCV library for that device’s architecture. Because OpenCV for Android SDK was still in its early stage, it did not support a couple of features which had to be implemented, such as, switching cameras at runtime, portrait mode, stretching frame to container, removing the alpha channel from the frame without introducing more operations. 23
Pulse: vital signs monitoring application Figure 3.4: Overview of the interaction between the implemented Android application and library. Figure 3.5: User interface of the implemented Android application, Pulse. 24
Pulse: vital signs monitoring application 3.3 Pulse: Android application The user interface of the implemented Android application, Pulse, is shown on figure 3.5. When the application is opened, the camera starts processing images and requests the user to place its face in front of the camera. If a face is detected the user is instructed to remain still in a bright place. Finally, if a cardiac pulse is detected, the heart rate estimated and the signal are shown on the top of the screen, while, the person’s face magnification is also shown. Three buttons exists on the top-right corner. From left to right, the first one, represented with a play icon, starts the record mode. The record mode averages all the heart rate values estimated in that time period. Pressing the button again finishes the record mode and displays the average of the beats per minute. This mode was used for the procedure described on section 4.2. The second button, represented with a camera icon, allows the application to switch between the front and back camera. The third and last button, represented with a wrench icon, opens a settings dialog, where the Eulerian Video Magnification may be enabled and disabled and its amplification value, α, can be changed. Also, an option to turn on and off the number of frames per second that the application is running at is available. 3.4 Summary This chapter starts by describing the main goal and motivation for developing a lightweight, realtime Eulerian Video Magnification-based method for the Android platform. Then, an overview of the implemented algorithm’s steps is described. The algorithm begins by detecting a person’s face and magnifying it using the Eulerian Video Magnification method. Then, it extracts a possible pulse signal by averaging the green channel of a rectangle’s face, which is validated, processed by detrending and normalization, and validated again, by verifying its shape and timing. Finally, the heart rate is estimated using the power spectrum technique to obtain a signals frequency. The chapter then details various implementations of the Eulerian Video Magnification method which were implemented: •EvmGdownIdeal, applies a spatial filter by computing a level of the Gaussian pyramid, and uses the Fourier transform to implement a temporal ideal bandpass filter; •EvmGdownIIR, applies the same spatial filter as the previous, but uses a temporal IIR bandpass filter, which was constructed from the subtraction of two first-order lowpass IIR filters, which are more suitable for a real-time implementation; •EvmLpyrIIR, applies the same temporal filter as above, but computes a full Laplacian pyramid for the spatial filter, where each level is amplified differently; •Performance optimized EvmGdownIIR, is implemented in C/C++, while the others were implemented in Java, and the spatial filter is modified to single resize operations but the result is similar to computing a level of the Gaussian pyramid. 25
Pulse: vital signs monitoring application Face detection uses the OpenCV object detector module. In order to increase performance, the face detector only executes every one second. Moreover, only the face’s rectangle is magnified, instead of the whole frame. Two phases for validating the extracted signal exists. First, the raw signal standard deviation is checked against a threshold. Then, the raw signal is detrended and normalized, and the processed signal shape and timing is verified by detecting its peaks. The algorithm is integrated into an Android application by using the JNI framework, so the Android SDK is capable of interacting with the native code. Finally, the resulting Android application, Pulse, user interface is described. 26
Chapter 4 Results This chapter provides the results obtained during this dissertation and the analysis of these. Section 4.1 reports several performance improvements to the implemented Eulerian Video Magnification method and the developed algorithm to estimate a person’s heart rate. Section 4.2 compares the measurements from the implemented Android application, Pulse, to a sphygmomanometer, and also, to another Android application by ViTrox that estimates a person’s heart rate using a different method. 4.1 Performance Smartphone devices have a low computational power and this was one of the main difficulties. The first implementations of the application were not fast enough and the implemented Android application running on a HUAWEI MediaPad tablet with the Android version 4.0.3 was only capturing around 2 frames per second. In order to improve the algorithm and application performance, metrics were obtained using the High performance C++ Profiler [And13]. This profiler was chosen because of its performance claim and easy integration in the project. The machine specifications on which all metrics were obtained are: Machine MacBook Pro, 15-inch, Late 2008 Processor 2.53 GHz Inter Core 2 Duo Memory 4 GB 1067 MHz DDR3 Operating System OS X Mountain Lion The input video used was the video face found at [WRS+13]. 27
Results 50 60 70 80 90 100 110 120 Average Heart Rate (bpm) 60 50 40 30 20 10 0 10 20 Difference in Heart Rate (bpm) Mean Mean+1.96SD Mean-1.96SD (a) Pulse and sphygmomanometer. 50 60 70 80 90 100 110 120 Average Heart Rate (bpm) 60 50 40 30 20 10 0 10 20 Difference in Heart Rate (bpm) Mean Mean+1.96SD Mean-1.96SD (b) ViTrox and sphygmomanometer. 50 60 70 80 90 100 110 120 Average Heart Rate (bpm) 60 50 40 30 20 10 0 10 20 Difference in Heart Rate (bpm) Mean Mean+1.96SD Mean-1.96SD (c) Pulse and sphygmomanometer, after physical exercise. 50 60 70 80 90 100 110 120 Average Heart Rate (bpm) 60 50 40 30 20 10 0 10 20 Difference in Heart Rate (bpm) Mean Mean+1.96SD Mean-1.96SD (d) Pulse and sphygmomanometer, only measurements with an heart rate lower than 70 bpm according to the sphygmomanometer. Figure 4.2: Bland-Altman plots demonstrating the agreement between the heart rate measurements obtained from a sphygmomanometer and an Android application: either Pulse, (a), (c), (d), which is the developed application, or the ViTrox application, (b). 34
Chapter 5 Conclusions This final chapter presents a review of the relevant information obtained from this work and an exposition of further work and research. Section 5.1 gives an overall description of the work done, from the performance improvements of the Eulerian Video Magnification method, to the creation of the Android application capable of estimating a person’s heart rate using the device’s camera. Finally, section 5.2 exposes future work that could follow the development of an Androidbased implementation of the Eulerian Video Magnification. 5.1 Objective satisfaction The main goal of this work was providing an Eulerian Video Magnification-based method capable of running on an Android device. To achieve that, various real-time implementations of the Eulerian Video Magnification method were developed with the aid of the image processing library OpenCV. However, these were not efficient enough to execute on a smartphone in real-time. Hence, a performance profiler was integrated into a desktop application, in order to increase the performance of the application and the Eulerian Video Magnification method, which was occupying 28% of the total CPU cycles used by the application. This Eulerian Video Magnification method implementation was using a temporal bandpass filter composed by subtracting two first-order IIR lowpass filters, which is more convenient for a real-time implementation than an ideal temporal filter implemented by applying the Fourier transform to each pixel for a video segment. The main performance boost was accomplished by replacing the multiple operations of Gaussian blurring and downsampling, suggested by [WRS+12], by a single resize operation using the OpenCV interpolation method AREA, which produces a similar result of the Gaussian filter. Moreover, the inverse operations of multiple upsampling and Gaussian blurring followed by an image 35
Conclusions resize for cases when the downsampled image size had to be rounded was also replaced by a single resize operation using the linear interpolation method. At the end, the Eulerian Video Magnification method implemented was occupying only 6% of the total CPU cycles used by the application, which corresponds to a performance improvement of 22% in comparison to the initial implementation. As an example of application of the developed Eulerian Video Magnification method, an Android application, named Pulse, was implemented which was capable of estimating a person’s heart rate by capturing and analyzing that person’s PPG signal. Since the implemented algorithm was developed in the programming language C/C++ for performance reasons, the integration into the Android platform was done through the use of JNI and the Android NDK. The application workflow started by grabbing an image from the device’s camera. A person’s face was detected using the OpenCV object detect module which was previously trained to detect human faces. A region of interest (ROI) of the person’s face would then be fed into the implemented Eulerian Video Magnification method to amplify color variations. The average of the ROI green channel was computed, in order to increase the signal-to-noise ratio, and stored. Along the time, these stored values represent a PPG signal of the underlying blood flow variations. The signal is further processed using the detrend method to remove trends from the signal without magnitude distortion. It is then validated as a cardiac pulse signal by detecting its peaks in order to verify its shape and timing. Finally, the heart rate estimation is computed by identifying the frequency with the higher power spectrum of the signal. In order to validate the heart rate estimations obtained by the implemented Android application, Pulse, measurements from 9 participants were compared to the readings of a sphygmomanometer. The agreement between the two according to the Bland-Altman plots analysis had a mean bias of −12.00 with 95% limits of agreement −33.13 to 9.13 bpm. Heart rate measurements above 70 bpm according to the sphygmomanometer were not being correctly estimated by the Pulse application. Removing those increased the agreement between the Pulse application estimations and sphygmomanometer measurements to a mean bias of −4.25 with 95% limits of agreement −13.43 to 4.93 bpm. 5.2 Future work Having developed a lightweight, real-time Eulerian Video Magnification-based method for the Android platform which goal is to amplify color variations, the performance of different variants of the Eulerian Video Magnification method could be improved. This would increase the usage of this method in other kinds of devices and in other kinds of applications. Other uses for the Eulerian Video Magnification method could be studied, such as, using it as a security camera to detect small motion by magnifying such motion, or to identify suspicious people by detecting its heart rate in a contact-free way. Another idea would be to use the Eulerian 36
Conclusions Video Magnification method with the objective of identifying if a person is drunk or not, based on the work of [KA12]. Nevertheless, the implemented Pulse application needs to improve its heart rate estimations accuracy, and its face detection module in order to not lose track of a person’s face. In addition, other vital signs could be monitored, such as, breathing rate. In order to support some features of the implemented Android application, Pulse, part of the OpenCV for Android SDK library had to be modified. These changes can be contributed back to the community, since the OpenCV support for the Android platform is still in its early stage. 37
Conclusions 38
Appendix A Performance metrics This appendix presents performance metrics for the desktop application implemented using the High performance C++ Profiler. For further details refer to section 4.1. Each performance metric contains two tables. The first is ordered by function structure and total cycles the CPU spent on that function. The second table is ordered by self cycles, which represents the total cycles the CPU spent on that function minus the total cycles the CPU spent on the children functions. The short descriptions of the performance metrics and the page number where each can be found follows: Appendix A.1 on page 40 Initial performance metrics. Appendix A.2 on page 42 Performance metrics using faster resize operations. Appendix A.3 on page 44 Performance metrics when face detection was executed every 10 frames instead of every frame. Appendix A.4 on page 47 Performance metrics with no resize face box and resize and draw face box back to frame operations since the EvmGdownIIR implementation always resizes to a predefined size. 39
CommandLine: pulsedesktopcpp Date: WedMar2016:25:022013 Rawruntime: 33628.91mcycles Totalcalls: 9258 rdtscoverhead: 35cycles Percalloverhead: 70cycles Estimatedoverhead: 0.6484mcycles Function Calls MCycles Avg SelfMCycles SelfAvg /Main 1 30524.8251(100%) 30524.8251 169.5595 169.5595 loop 302 30355.2656(99%) 100.5141 1.9295 0.0064 voidWindow::update(...) 301 18192.5399(60%) 60.4403 1.1025 0.0037 voidPulse::onFrame(...) 301 15630.5432(51%) 51.9287 0.7415 0.0025 moreboxes 301 12688.4674(42%) 42.1544 1.2613 0.0042 voidPulse::onFace(...) 301 12685.8558(42%) 42.1457 3.5512 0.0118 voidEvmGdownIIR::onFrame(...) 301 8507.6548(28%) 28.2646 2.8293 0.0094 pyrUp 300 3472.5267(11%) 11.5751 3472.5267 11.5751 pyrDown 301 1988.4146(7%) 6.6060 1988.4146 6.6060 convertto8bit 300 1603.1581(5%) 5.3439 1603.1581 5.3439 addbacktooriginalframe 300 811.3654(3%) 2.7046 811.3654 2.7046 converttofloat 301 604.0527(2%) 2.0068 604.0527 2.0068 temporalfilter 300 23.2083(0%) 0.0774 23.2083 0.0774 amplify 300 2.0904(0%) 0.0070 2.0904 0.0070 first 1 0.0093(0%) 0.0093 0.0093 0.0093 voidcv::detrend(...) 301 1538.8180(5%) 5.1124 1538.8180 5.1124 resizefacebox 301 1270.4278(4%) 4.2207 1270.4278 4.2207 resizeanddrawfaceboxbacktoframe 301 1214.4998(4%) 4.0349 1214.4998 4.0349 drawing 301 104.8707(0%) 0.3484 104.8707 0.3484 voidcv::meanFilter(...) 301 30.0930(0%) 0.1000 30.0930 0.1000 pushbackrawandtimestamp 301 8.7693(0%) 0.0291 8.7693 0.0291 voidcv::normalization(...) 301 4.5634(0%) 0.0152 4.5634 0.0152 shiftrawandtimestamp 201 2.0371(0%) 0.0101 2.0371 0.0101 bpm 10 0.5708(0%) 0.0571 0.5708 0.0571 voidPulse::Face::updateBox(...) 301 1.2164(0%) 0.0040 1.1854 0.0039 voidcv::interpolate(...) 301 0.0310(0%) 0.0001 0.0310 0.0001 intPulse::Face::nearestBox(...) 300 0.1339(0%) 0.0004 0.1339 0.0004 detectfaces 301 2941.3343(10%) 9.7719 2941.3343 9.7719 imshow 301 2555.0751(8%) 8.4886 2555.0751 8.4886 voidWindow::drawFps(...) 301 5.8191(0%) 0.0193 0.2972 0.0010 fpsdrawing 301 5.2947(0%) 0.0176 5.2947 0.0176 fpsstring 10 0.1285(0%) 0.0128 0.1285 0.0128 boolWindow::Fps::update() 301 0.0987(0%) 0.0003 0.0830 0.0003 fpstick 10 0.0157(0%) 0.0016 0.0157 0.0016 waitkey 301 9892.1852(32%) 32.8644 9892.1852 32.8644 capture 302 2268.6110(7%) 7.5120 2268.6110 7.5120 40
Function Calls SelfMCycles SelfAvg Functionssortedbyselftime waitkey 301 9892.1852(32%) 32.8644 pyrUp 300 3472.5267(11%) 11.5751 detectfaces 301 2941.3343(10%) 9.7719 imshow 301 2555.0751(8%) 8.4886 capture 302 2268.6110(7%) 7.5120 pyrDown 301 1988.4146(7%) 6.6060 convertto8bit 300 1603.1581(5%) 5.3439 voidcv::detrend(...) 301 1538.8180(5%) 5.1124 resizefacebox 301 1270.4278(4%) 4.2207 resizeanddrawfaceboxbacktoframe 301 1214.4998(4%) 4.0349 addbacktooriginalframe 300 811.3654(3%) 2.7046 converttofloat 301 604.0527(2%) 2.0068 /Main 1 169.5595(1%) 169.5595 drawing 301 104.8707(0%) 0.3484 voidcv::meanFilter(...) 301 30.0930(0%) 0.1000 temporalfilter 300 23.2083(0%) 0.0774 pushbackrawandtimestamp 301 8.7693(0%) 0.0291 fpsdrawing 301 5.2947(0%) 0.0176 voidcv::normalization(...) 301 4.5634(0%) 0.0152 voidPulse::onFace(...) 301 3.5512(0%) 0.0118 voidEvmGdownIIR::onFrame(...) 301 2.8293(0%) 0.0094 amplify 300 2.0904(0%) 0.0070 shiftrawandtimestamp 201 2.0371(0%) 0.0101 loop 302 1.9295(0%) 0.0064 moreboxes 301 1.2613(0%) 0.0042 voidPulse::Face::updateBox(...) 301 1.1854(0%) 0.0039 voidWindow::update(...) 301 1.1025(0%) 0.0037 voidPulse::onFrame(...) 301 0.7415(0%) 0.0025 bpm 10 0.5708(0%) 0.0571 voidWindow::drawFps(...) 301 0.2972(0%) 0.0010 intPulse::Face::nearestBox(...) 300 0.1339(0%) 0.0004 fpsstring 10 0.1285(0%) 0.0128 boolWindow::Fps::update() 301 0.0830(0%) 0.0003 voidcv::interpolate(...) 301 0.0310(0%) 0.0001 fpstick 10 0.0157(0%) 0.0016 first 1 0.0093(0%) 0.0093 41
CommandLine: pulsedesktopcpp Date: TueMar2616:34:022013 Rawruntime: 28482.10mcycles Totalcalls: 9258 rdtscoverhead: 35cycles Percalloverhead: 70cycles Estimatedoverhead: 0.6484mcycles Function Calls MCycles Avg SelfMCycles SelfAvg /Main 1 26198.4978(100%) 26198.4978 233.9525 233.9525 loop 302 25964.5453(99%) 85.9753 1.7767 0.0059 waitkey 301 12363.3849(47%) 41.0744 12363.3849 41.0744 voidWindow::update(...) 301 11412.7939(44%) 37.9163 1.2515 0.0042 voidPulse::onFrame(...) 301 9042.7736(35%) 30.0424 1.1990 0.0040 equalormoreboxesthanfaces 301 6080.1116(23%) 20.1997 2.2855 0.0076 voidPulse::onFace(...) 301 6076.7600(23%) 20.1886 3.9544 0.0131 voidEvmGdownIIR::onFrame(...) 301 3638.0518(14%) 12.0866 1.4819 0.0049 convertto8bit 300 1607.4122(6%) 5.3580 1607.4122 5.3580 pyrUp 300 583.2825(2%) 1.9443 583.2825 1.9443 converttofloat 301 561.4179(2%) 1.8652 561.4179 1.8652 pyrDown 301 510.0373(2%) 1.6945 510.0373 1.6945 addbacktooriginalframe 300 361.6961(1%) 1.2057 361.6961 1.2057 temporalfilter 300 11.8974(0%) 0.0397 11.8974 0.0397 amplify 300 0.7884(0%) 0.0026 0.7884 0.0026 first 1 0.0381(0%) 0.0381 0.0381 0.0381 voidcv::detrend(...) 301 1552.5092(6%) 5.1578 1552.5092 5.1578 resizeanddrawfaceboxbacktoframe 301 430.7046(2%) 1.4309 430.7046 1.4309 resizefacebox 301 307.4483(1%) 1.0214 307.4483 1.0214 drawing 301 95.1404(0%) 0.3161 95.1404 0.3161 voidcv::meanFilter(...) 301 32.0769(0%) 0.1066 32.0769 0.1066 pushbackrawandtimestamp 301 9.1591(0%) 0.0304 9.1591 0.0304 voidcv::normalization(...) 301 5.1992(0%) 0.0173 5.1992 0.0173 shiftrawandtimestamp 201 1.9278(0%) 0.0096 1.9278 0.0096 bpm 10 0.5883(0%) 0.0588 0.5883 0.0588 voidPulse::Face::updateBox(...) 301 0.9015(0%) 0.0030 0.8720 0.0029 voidcv::interpolate(...) 301 0.0295(0%) 0.0001 0.0295 0.0001 intPulse::Face::nearestBox(...) 300 0.1646(0%) 0.0005 0.1646 0.0005 detectfaces 301 2961.4630(11%) 9.8387 2961.4630 9.8387 imshow 301 2362.7211(9%) 7.8496 2362.7211 7.8496 voidWindow::drawFps(...) 301 6.0477(0%) 0.0201 0.4610 0.0015 fpsdrawing 301 5.3400(0%) 0.0177 5.3400 0.0177 boolWindow::Fps::update() 301 0.1247(0%) 0.0004 0.1096 0.0004 fpstick 10 0.0151(0%) 0.0015 0.0151 0.0015 fpsstring 10 0.1219(0%) 0.0122 0.1219 0.0122 capture 302 2186.5898(8%) 7.2404 2186.5898 7.2404 42
Function Calls SelfMCycles SelfAvg Functionssortedbyselftime waitkey 301 12363.3849(47%) 41.0744 detectfaces 301 2961.4630(11%) 9.8387 imshow 301 2362.7211(9%) 7.8496 capture 302 2186.5898(8%) 7.2404 convertto8bit 300 1607.4122(6%) 5.3580 voidcv::detrend(...) 301 1552.5092(6%) 5.1578 pyrUp 300 583.2825(2%) 1.9443 converttofloat 301 561.4179(2%) 1.8652 pyrDown 301 510.0373(2%) 1.6945 resizeanddrawfaceboxbacktoframe 301 430.7046(2%) 1.4309 addbacktooriginalframe 300 361.6961(1%) 1.2057 resizefacebox 301 307.4483(1%) 1.0214 /Main 1 233.9525(1%) 233.9525 drawing 301 95.1404(0%) 0.3161 voidcv::meanFilter(...) 301 32.0769(0%) 0.1066 temporalfilter 300 11.8974(0%) 0.0397 pushbackrawandtimestamp 301 9.1591(0%) 0.0304 fpsdrawing 301 5.3400(0%) 0.0177 voidcv::normalization(...) 301 5.1992(0%) 0.0173 voidPulse::onFace(...) 301 3.9544(0%) 0.0131 equalormoreboxesthanfaces 301 2.2855(0%) 0.0076 shiftrawandtimestamp 201 1.9278(0%) 0.0096 loop 302 1.7767(0%) 0.0059 voidEvmGdownIIR::onFrame(...) 301 1.4819(0%) 0.0049 voidWindow::update(...) 301 1.2515(0%) 0.0042 voidPulse::onFrame(...) 301 1.1990(0%) 0.0040 voidPulse::Face::updateBox(...) 301 0.8720(0%) 0.0029 amplify 300 0.7884(0%) 0.0026 bpm 10 0.5883(0%) 0.0588 voidWindow::drawFps(...) 301 0.4610(0%) 0.0015 intPulse::Face::nearestBox(...) 300 0.1646(0%) 0.0005 fpsstring 10 0.1219(0%) 0.0122 boolWindow::Fps::update() 301 0.1096(0%) 0.0004 first 1 0.0381(0%) 0.0381 voidcv::interpolate(...) 301 0.0295(0%) 0.0001 fpstick 10 0.0151(0%) 0.0015 43
Performance metrics 50
References [And13] Andrew. High performance c++ profiling | andrew. http://floodyberry.wordpress. com/2009/10/07/high-performance-cplusplus-profiling/, March 2013. [BA83] P. Burt and E. Adelson. The laplacian pyramid as a compact image code. Communications, IEEE Transactions on, 31(4):532–540, 1983. [Com94] P. Comon. Independent component analysis, a new concept? Signal processing, 36(3):287–314, 1994. [Gre97] EF Greneker. Radar sensing of heartbeat and respiration at a distance with applications of the technology. In Radar 97 (Conf. Publ. No. 449), pages 150–154. IET, 1997. [GSMP07] M. Garbey, N. Sun, A. Merla, and I. Pavlidis. Contact-free measurement of cardiac pulse based on the analysis of thermal imagery. Biomedical Engineering, IEEE Transactions on, 54(8):1418–1426, 2007. [HZCS08] Sijung Hu, Jia Zheng, Vassilios Chouliaras, and Ron Summers. Feasibility of imaging photoplethysmography. In BioMedical Engineering and Informatics, 2008. BMEI 2008. International Conference on, volume 2, pages 72–75. IEEE, 2008. [IDC13] IDC. Android marks fourth anniversary since launch with 75.0in third quarter, according to idc. http://www.idc.com/getdoc.jsp?containerId=prUS23771812, January 2013. [Its13] OpenCV Developers Team: Itseez. About | opencv. http://opencv.org/about. html, January 2013. [KA12] Georgia Koukiou and Vassilis Anastassopoulos. Drunk person identification using thermal infrared images. International Journal of Electronic Security and Digital Forensics, 4(4):229–243, 2012. [LFSK06] C. Liu, W.T. Freeman, R. Szeliski, and S.B. Kang. Noise estimation from a single image. In Computer Vision and Pattern Recognition, 2006 IEEE Computer Society Conference on, volume 1, pages 901–908. IEEE, 2006. [LM02] Rainer Lienhart and Jochen Maydt. An extended set of haar-like features for rapid object detection. In Image Processing. 2002. Proceedings. 2002 International Conference on, volume 1, pages I–900. IEEE, 2002. [LOCS95] Daniel A Litvack, Tim F Oberlander, Laurel H Carney, and J Philip Saul. Time and frequency domain methods for heart rate variability analysis: a methodological comparison. Psychophysiology, 32(5):492–504, 1995. 51
REFERENCES [LTF+05] C. Liu, A. Torralba, W.T. Freeman, F. Durand, and E.H. Adelson. Motion magnification. In ACM Transactions on Graphics (TOG), volume 24, pages 519–526. ACM, 2005. [MBA86] J Martin Bland and DouglasG Altman. Statistical methods for assessing agreement between two methods of clinical measurement. The lancet, 327(8476):307–310, 1986. [NI10] Bistra Nenova and Ivo Iliev. An automated algorithm for fast pulse wave detection. International Journal Bioantomation, 14(3):203–216, 2010. [PB90] Stephen W Porges and Robert E Bohrer. The analysis of periodic processes in psychophysiological research. 1990. [Phi13] Philips. Philips vital signs camera. http://www.vitalsignscamera.com, January 2013. [PMP10] M.Z. Poh, D.J. McDuff, and R.W. Picard. Non-contact, automated cardiac pulse measurements using video imaging and blind source separation. Optics Express, 18(10):10762–10774, 2010. [PMP11] M.Z. Poh, D.J. McDuff, and R.W. Picard. Advancements in noncontact, multiparameter physiological measurements using a webcam. Biomedical Engineering, IEEE Transactions on, 58(1):7–11, 2011. [Por13] Fraunhofer Portugal. Fraunhofer portugal - about us. http://www.fraunhofer.pt, January 2013. [Tec13] ViTrox Technologies. What’s my heart rate. http://www.whatsmyheartrate.com, May 2013. [TRaK02] Mika P Tarvainen, Perttu O Ranta-aho, and Pasi A Karjalainen. An advanced detrending method with application to hrv analysis. Biomedical Engineering, IEEE Transactions on, 49(2):172–175, 2002. [UT93] S.S. Ulyanov and V.V. Tuchin. Pulse-wave monitoring by means of focused laser beams scattered by skin surface and membranes. In OE/LASE’93: Optics, Electro- Optics, & Laser Applications in Science& Engineering, pages 160–167. International Society for Optics and Photonics, 1993. [VJ01] Paul Viola and Michael Jones. Rapid object detection using a boosted cascade of simple features. In Computer Vision and Pattern Recognition, 2001. CVPR 2001. Proceedings of the 2001 IEEE Computer Society Conference on, volume 1, pages I–511. IEEE, 2001. [VSN08] Wim Verkruysse, Lars O Svaasand, and J Stuart Nelson. Remote plethysmographic imaging using ambient light. Optics express, 16(26):21434–21445, 2008. [WMVdS05] FP Wieringa, F Mastik, and AFW Van der Steen. Contactless multiple wavelength photoplethysmographic imaging: a first step toward “spo2 camera” technology. Annals of biomedical engineering, 33(8):1034–1041, 2005. 52
REFERENCES [WRS+12] Hao-Yu Wu, Michael Rubinstein, Eugene Shih, John Guttag, Frédo Durand, and William T. Freeman. Eulerian video magnification for revealing subtle changes in the world. ACM Trans. Graph. (Proceedings SIGGRAPH 2012), 31(4), 2012. [WRS+13] Hao-Yu Wu, Michael Rubinstein, Eugene Shih, John Guttag, Frédo Durand, and William T. Freeman. Eulerian video magnification. http://people.csail.mit.edu/ mrub/vidmag/, January 2013. 53