Measuring heart rate through the webcam

Hi everyone!

I hope you are doing good.

I want to create an experiment to record the heart rate (through the webcam - I have implementation for this) of the users while showing images(positive, negative, neutral).

What specifically went wrong when you tried that?:
I’m very new to psychopy, I can able create a simple experiment by randomizing the pictures, now I want to measure the heart rate of the user during that picture through the webcam (i have the implementation to measure the heart rate through the webcam in python). How can I connect the heart rate measuring code in the pyschopy, please could anyone help me how can is that possible?

Thanks in Advance.

Hi There,

This sounds like a really cool (an advanced!) experiment. Just to check, are you trying to run this locally? (not online) If so, you’ll want some extra python libraries.

The first step will be learning how to stream the webcam in your experiment, here is a demo showing how to do that
webcam.psyexp (7.5 KB)

The next step is pretty advanced and I haven’t played with much yet (but it’s good fun!). You’ll want to import a python library to extract heart rate from the web cam, maybe something like this looks like a good place to start? GitHub - 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.

Hope this helps to get started!
Becca

1 Like

Hi Becca,

Thanks for responding, I hope you are doing good and having a great week.

Yes, I have referred to that GitHub repo I worried that ‘‘where can I include that code in psychopy??, how can I include that??’’

I appreciate your response.

Thanks,
Dixith