Heart rate estimation using PPG data from Mobile Camera AIM: To Record a 15 second long video by keeping finger over the camera with flash on. To use the video recordings to perform PPG and estimate heart rate.
Link to video demonstration: https://youtube.com/shorts/elXEM3nB6Fs
Approach:
- Finger was put on camera and a 15 second video was recorded with flash on in each case.
- The video was imported to python using open CV2 and a video data object was created. FPS, frame count were determined.
- The first few frames and last few frames were dropped as a data pre processign measure as they contain most of the error. e.g - putting finger and removing finger, stabilizing time etc
- For each image of the video, pixels in thge middle were selected, and average was calculated for Red, Green and Blue colors
- An array for each color was maintained to store average value. The number of items in the array were equal to the number of images.
- The array data was plotted seperately for reference.
- The red array was selected for further processing and determination of results as Red gave best results graphically [ASSUMPTION 1].
- The array is now treated as a signal.
- The signal is passed through a Lowpass filter, followed by a high pass filter to remove unwanted frequencies. The constants were roughly determined.
- Then, the signal was squared to elongate it, so that it is easy to determine peaks [ASSUMPTION 2]
- A moving average filter was applied to remove any unwanted spikes. The window size was roughly estimated.
- The signal was printed for reference.
- Peaks were detected using peak detection algorithm from SCIPY.SIGNAL library and average time between peaks were calculated.
- Heart rate was calculated and compared with real data to calculate error.
- The process was repeated for 4 more different person.
OBSERVATION:
Data is uploaded as image file as observation.png Data is for v1 of this code. V2 is much improved.
Mean of all errors: 7.63%
CONCLUSION: Position of finger plays important role in data quality, placing finger on camera only gave better results than placing finger on both camera and flash. The pressure applied by finger should be gentle. Flash should be ON otherwise error is more than 25%. Light skin color are better as they let in and out more light.
References:
#https://www.researchgate.net/publication/329896875_Image_Analysis_on_Fingertip_Video_To_Obtain_PPG #https://docs.opencv.org/3.4/d8/dfe/classcv_1_1VideoCapture.html #https://docs.scipy.org/doc/scipy/reference/signal.html