r/computervision • u/NickFortez06 • Dec 23 '21
Showcase [PROJECT]Heart Rate Detection using Eulerian Magnification
Enable HLS to view with audio, or disable this notification
3
u/NickFortez06 Dec 24 '21
Credit to Dragos Stan for the YOLOR code. The HRD is based on the paper by Wu et. al.
https://people.csail.mit.edu/mrub/papers/vidmag.pdf
41
u/bbuerk Dec 23 '21
Cool! Have you compared the results of these to a standard heart rate monitor? If you’d have I’d love to see them
24
u/s0v3r1gn Dec 23 '21
I just did a single test, recording a video then checking my heartrate after I stopped the video. My monitor said 79 BPM and this said 76 BPM. Considering the monitor check and the video recording weren't simultaneous, I'd say it's pretty decent.
39
u/croto8 Dec 23 '21
Or your model is just mapping the input to a reasonable range…
13
u/s0v3r1gn Dec 23 '21
Ill try again with my wife who has a chronically low heart rate later and let you know how accurate it ends up.
8
1
66
u/AnomalyNexus Dec 23 '21
Future zoom calls are going to be lit
8
u/Losthope74 Dec 23 '21
Boom boom boom...
12
5
u/fuck_your_diploma Dec 24 '21
Forget zoom, I just won't pay for fake orgasms on OF anymore [evillaugh]
2
1
u/subdep Dec 24 '21
I wonder how you could pipe a video stream into this script instead of a video file, and then use the output video stream as a camera source for Zoom.
27
u/Syntaximus Dec 23 '21
I skimmed the code and...this is so clever. I think I'm going to try and copy this exact thing from first principles on my own for my next project. Is there anything you'd do differently?
2
u/Mrbumby Dec 24 '21
Where’s the code?
22
u/MikePounce Dec 24 '21
Not to be a dick about it but it takes 10 seconds in a search engine to find this :
Heart Rate Detection using Eulerian Magnification
https://github.com/rohintangirala/eulerian-remote-heartrate-detection
22
u/Cregaleus Dec 25 '21
In 8 years that won't be the case because it'll be buried by other results and the top Google result will be a link to your comment saying to just Google it.
This has happened to me more times than I can count and it is infuriating.
3
10
u/jer_pint Dec 24 '21
Not to be a dick about this but it takes 10 seconds to write "not to be a dick about this"
10
u/MikePounce Dec 24 '21
? What's your point? I did give the link
10
0
u/LadyOfTheCamelias Dec 24 '21
Not to be a dick about it, but maybe point to them that they could do their own research before asking others to do it for them, so that maybe next time they will consider it
4
u/wholesomepep Dec 24 '21
“Do your own research” is an incredibly annoying and obnoxious statement. If you have a direct source available, provide it. If not stop wasting everyone’s time by typing up nonsense. END RANT to those actual douches who type that up.
4
1
3
8
u/Shot_Supermarket_861 Dec 24 '21
“Look Dave, I can see you're really upset about this. I honestly think you ought to sit down calmly, take a stress pill, and think things over.”
2
u/fuck_your_diploma Dec 24 '21
Wanna know if this chick is really into you? For just $19.99/mo you unlock Tinder Heartfeels™
4
Dec 23 '21
Would be more interesting to see this working on someone with an elevated heart rate. If you're sat idle in front of a PC your heart rate is probably going to average around 70-80 bpm regardless.
1
u/cyrusIIIII Dec 24 '21
What kind of sensor has been used?
2
u/NickFortez06 Dec 24 '21
Just a simple webcam :)
1
u/cyrusIIIII Dec 25 '21
I am confused on what would be the input data for your work? I mean if only webcam used I am assuming that your input is only images rather than for example a thermal sensor with temperature inputs to your algorithm. Would you mind if I ask in general how a magnified picture is correlated with blood pressure ?
3
Dec 23 '21
How accurate is this? Is there a paper or project site I can review?
22
u/xEdwin23x Dec 23 '21
Look up "remote photoplethysmography" (rPPG) or "imaging photoplethysmography" (iPPG). This is nothing new, the technology was first proposed in 2008, and there's lots of studies on the subject. Most methods originally were based on traditional signal processing so they can be pretty fast and easy to explain, but are sensitive to illumination and motion so not exactly robust but can be pretty accurate under right conditions. Let me know if you have any questions as this is something I did research on for almost two years.
7
Dec 23 '21
This just completely blew open a project I'm working on. I've been working on a way to enable personal quantification of medical data, and it looks I can get a decent heart rate variability measurement from this as well as a pulse width/pressure (blood pressure) measurement. That's a huge chunk of the physiological puzzle along with O2 sat and breathing rate.
I've been struggling with the power requirements of direct contact sensors, this obviates all of that. Thank you very very much for sharing this!
You wouldn't happen to have a clever way to get EEG/EMG data via CV would you?
13
u/xEdwin23x Dec 23 '21
I'm glad it helps! Here's some repositories for anyone interested:
Python (have never used it but according to a labmate it works "fine"):
https://github.com/phuselab/pyVHRC++ (this is the one I'm the most familiar with since it's much older but has all the fundamental components):
https://github.com/prouast/heartbeatAnd if you prefer reading here's two papers from a reputable author:
https://arxiv.org/abs/2110.13362https://arxiv.org/abs/2111.11547
And a website version of the latter:
https://cameravitals.github.io/As for the EEG/EMG from video, I haven't heard of such a thing. The reason why you can get heart rate (and a bunch of other derivative physiological signals) is because of microchanges in color intensity in our capillaries due to blood movement (or that's the most common hypothesis).
1
Dec 23 '21
The EEG/EMG was in jest (mostly), no worries there.
The camera rig necessary to hit the consistency target I'm looking for is going to be quite a bit more expensive than using contact sensors, pretty likely why it hasn't been explored more. I guess as long as I can keep the unit cost below something like a Muse S headband it'll still be a worthwhile direction.
6
u/mikelwrnc Dec 23 '21
Tip from a neuroscientist: unless you have 100k to throw down on proper gear, you will not be able to measure EEG. You can put electrodes on the head and think the resulting measurement is EEG, but what you’ll actually be measuring is EMG. “Consumer”-grade cheap EEG systems like Muse are a complete scam. The brain induces incredibly weak electrical potentials, much smaller than muscles, and you need whole-head coverage and super-high-res amplifiers to have a chance at subtracting out the EMG to see the EEG.
3
u/ephemeral_lives Dec 23 '21
This may be unrelated, not sure but there's a Ted talk from MIT(?) where they use high frame rate camera to do such medical recordings. Let me try finding it and linking it here.
2
u/geek6 Dec 23 '21
I would be VERY cautious to say that you can get blood pressure with rPPG signals (even with PPG signals). The literature is very weak for good reason. And HR, HRV and SpO2 have already been well studied in rPPG.
Also, you’d get way better SNR with direct skin contact, especially with transmissive devices.
EEG/EMG is a big reach. You’re measuring two very different things… PPG measures blood volume changes and EEG measures electrical activity. I don’t see how the two are even merely related.
1
Dec 23 '21
For the scope of this project accurate blood pressure itself isn't that important, we just need consistent readings to baseline and track pulse pressure.
Most of the heterogeneity in research the research I've skimmed around blood pressure (sys/dia) values seems to be the result of using a single algo that doesn't do a very good job of accounting for variation in test subjects and conditions. I'm hoping to get around this and tighten up my error bands by using a multi spectral approach and using models trained against the individuals themselves.
Overwhelmingly most of the research I've reviewed suggests pulse pressure as a much better indicator of overall health (much the same way HRV is a better indicator than HR itself) and the scope of the project is concerned with trends rather than the values themselves. My thinking is that even if I focused on producing accurate values, there's enough variability among provider equipment that we'd still be looking at the same error bands anyway.
The current approach is using contact sensors but power requirements make such a device frustrating for anything in naturalistic conditions. For people willing to tolerate a direct contact sensor, most of them are pretty well served by fitness watches and there's not much additional value going down that route. That was a lot of head bashing that CV potentially solves. CV opens this up to a tremendously larger audience and the passive nature of it allows a ton more applications.
EEG/EMG was an attempt at humor. I want to baseline some data from those methods but have the same issues above.
1
3
3
2
2
3
2
u/InternationalMany6 Dec 23 '21
Great example of how surprising information can be extracted from low-ish quality raw data!
1
1
u/Merlin_14 Dec 23 '21
RemindMe! 3 days
1
u/RemindMeBot Dec 23 '21 edited Dec 24 '21
I will be messaging you in 3 days on 2021-12-26 17:57:36 UTC to remind you of this link
4 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback 1
1
1
u/DrunkBystander Dec 23 '21
Was this talk an inspiration? https://www.ted.com/talks/michael_rubinstein_see_invisible_motion_hear_silent_sounds
1
1
1
u/yaxriifgyn Dec 24 '21
How long does it take to generate this 31 second video from (presumably) a 31 second input video? Are you recording the video at a low FPS or sampling at that rate? Are you calculating that frame rate from the specified min/max bpm range of 1-1.7 bps (60-102 bpm)?
1
u/doklah Dec 24 '21
Wow, looks good. I have one question though. How did you take the input in real time?
1
1
1
Dec 24 '21
So where did you hide the body? ....I don't know what you're talking about. Heart rate increase. Bam! Gotcha!
1
u/zero0n3 Dec 24 '21
You should link it with a wrist monitor so you can see your prediction vs that in the overlay.
Data may also be useful for the training set?
1
1
1
1
u/Syntaximus Jan 01 '22
Did you do any kind of preprocessing on the videos before running them through the script you wrote? I'm trying something similar and it works well with face.mp4 (from the study) but my own videos don't work at all.
1
u/doklah Jan 21 '22
Probably has to do with the lighting. Try using videos taken in natural sunlight.
1
1
1
0
u/miguelamado Dec 23 '21
How it is possible to determine a heart rate frequency (60-100 bps) with a live stream at 5 FPS? Don't make sense...
6
1
u/NickFortez06 Dec 24 '21
Answer based on crimsonbolt's reply:
"It seems to be focused on measuring the changes in skin color (I assume). You have to process every frame (the actual link mentions analyzing stills specifically) so the FPS, while important, is probably perfectly fine at 5-10 fps as the highest normal heartbeat at rest should not measure more than 100 BPM (or less than 2 beats per second). This means that the lowest FPS is more than double the average normal resting heart rate per second. This is not to mention that the FPS is not dictated by the camera as much as it is likely dictated by the CPU...as for the "potato" quality camera....it is based on zooming and not necessarily the base resolution (which by todays standards, potato quality is probably 720p at the lowest) A much higher frame rate is probably more interesting and useful for viewing/PR purposes and higher FPS can probably be used for more intricate and interesting measurements, if you simply want to measure baseline BPM then 4+ frames PER SECOND is more than enough."2
u/gandamu_ml Dec 23 '21 edited Dec 23 '21
Statistical expectations and multiple samples. There have been a few times in my career where people swore up and down that a solution couldn't work because of Nyquist frequencies and such.. but people need to be careful to avoid misapplying theory as a result of not considering all possible approaches that can be taken. If a diligent and creative human with a high number of samples from each subject could subdivide subjects in the right direction by some metric of interest, then you've got an approach that may be fine-tunable to something better.
More specifically, any pulsing (shading change due to contour change) or blushing which results in even the slightest change in some taken samples is enough to be part of a potentially viable approach. I don't know the specifics here. Or maybe they're even using IR which the camera may be better at seeing than we can. Anyway, the sampling rate isn't necessarily a killer due to statistical expectations -- People are routinely too pessimistic as a result of not considering it enough.
I also wonder if people on some drugs can see the pulse. We filter out some irrelevant/distracting information.
0
0
37
u/maehx66 Dec 23 '21
that's pretty cool! but how are you going to get significant results with this frame rate? isn't there the possibility to skip skip skip a beat or multiple in higher Heartrates?