Pseudo-electrocardiogram

Concept

As the heart pumps, fresh oxygen rich blood is sent throughout the body as carbon dioxide is excreted. This process can be viewed by pressing one’s finger against their computer’s webcam and holding a light still behind it. The image will become noticeably darker with each beat.

Process

I use opencv to get webcam frames and calculate the frame’s brightness by averaging the brightness of each pixel. I create a history array to store each frame’s brightness for graphing and I use this history to calculate the beats per minute by measuring the average time elapsed between each peak. Each peak or trough must come within a calculated percentage of the max and min line to be considered when calculating BPM. To make the graph look nice I use the minimum value of the history to be the lowest point and vice versa and interpolate the other values based on these values.

Result

It works really well as demonstrated in the following video considering it was done using a webcam.

Code: OSTRANDER4

This entry was posted in Exercise 5. Bookmark the permalink.

Leave a Reply