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.14k stars 592 forks source link

Feature Request: ICA on RGB #23

Open mike-lawrence opened 10 years ago

mike-lawrence commented 10 years ago

I see that your code runs an FFT on the green channel only, possibly missing out on data from the other channels. I've seen other implementations pass the RGB channel data through ICA then passing the resulting independent components through FFT. (Actually, they chose a single component to pass through the FFT, but it seems uncertain whether the same component number would contain the pulse signal every time. It therefore seems more robust to pass all channels through FFT and check them all for power in the expected range of human pulse rates.)

mike-lawrence commented 10 years ago

An possibly equivalent and certainly easier solution might be to do the FFT on the H channel after converting to HSV.

thearn commented 10 years ago

I've done some experimentation on using both PCA and FastICA (via the Python MDP library) across all three color channels. Surprisingly, the projection ends up being highly weighted towards the green channel, with a small contribution from red and almost none from blue. The improvement was less than I had hoped, though this may depend on specifics of the selected algorithm, of course.

You can try this yourself, by either adding in an ICA calculation step in the execute() method of an existing component, or by defining a component and adding it to the overall assembly.

I may continue to do some experimentation along these lines soon, including some tests with multiple collection locations among other experimental features. If so, I will push this up as it's own branch.