thearn / webcam-pulse-detector

A python application that detects and highlights the heart-rate of an individual (using only their own webcam) in real-time.
Other
3.16k stars 596 forks source link

Zero padding for interpolation of the input sample in frequency space #12

Closed maym86 closed 11 years ago

maym86 commented 11 years ago

Maybe I missed it in the code but you should initialise the sample array to the full length and fill it with zeros. I think your code just appends to the sample so it gradually grows. Filling with zeroes creates interpolation of the signal in the frequency space making the resolution of your initial estimate higher. A longer FFT result has more frequency bins that are more closely spaced in frequency thus creating a better estimate of pulse from a small sample.

thearn commented 11 years ago

Good catch, it does make more sense than the current implementation. It's actually a change to the BufferFFT component that I've made on a local branch but haven't pushed to master yet. I'll be updating with that along with some other changes shortly. I need to do some more testing, because there is more involved than just zero padding the data samples - the sample timestamps lists needs to be extended as well.