MAKING A GUI IS HARD!
I was away last week but was still working on Python. This week I managed to get a graphical user interface working that showed both the output from the camera as a signal but also from a pulse sensor as well.
Here is my short script to actually measure the frame rate of the webcam. My Macbook Air does 30 fps which is very common.
I spend the majority of the week learning to work with GUI elements in Python. This means windows, buttons, images, and general stuff where a program runs in a window instead of in the terminal. I had to learn how to add plots, and scale, and “listen” for events like a mouse click. In Python this is called signals and having a python program act on a signal is done with a slot. You create a program component (a function) to respond when a signal is given.
Here is an animated GIF showing a comparison of the signals from the camera versus a finger pulse sensor. The top window is the raw camera feed. Note my finger is covering the camera fully here. I have yet to get the peak detection to work very well.
First iteration: got the camera signal and image to display in a GUI.
https://t.co/EQy5gr0d2X I can actually see my pulse. It’s coming from my forehead and the signal is noisy but there is signal! @PathsUp @RiceU_STEM This is my implementation of a remote PPG using Python.
— Jimmy Newland (@newtonsenigma) June 25, 2019
Second iteration: got the camera signal and the
https://t.co/G9liIAE2Ni Slow but steady progress. Here I am comparing the signal from a webcam with a finger over it to a pulse sensor attached to the same finger on the other hand. They seem pretty synchronized. @PathsUp @RiceU_STEM
— Jimmy Newland (@newtonsenigma) June 27, 2019
I also added Butterworth bandpass filtering to the signal which seems to need my signal to noise ratio to improve. And I am using HeartPy to find the peaks in the signal. Both processes worked to some degree but the whole system is so environment dependent that I can’t say it is in beta… more like alpha version. But progress is progress.
I also wrote code to save the streams of data as CSV files which can be processed as a whole after the fact.
I want to add some other stuff to the GUI like buttons to start and stop and the readings from the pulse sensor and the camera. Plus signal analysis using a fast Fourier transform is going to be hard.