/img/portrait-square.jpg

Samuel Pröll - Personal homepage

Digital filters for live signal processing in Python

Digital filters are commonplace in biosignal processing. And the SciPy library offers a strong digital signal processing (DSP) ecosystem that is exceptionally well documented and easy to use with offline data. However, there is shockingly little material online on DSP in Python for real-time applications. In a live graphical interface (like yarppg), the signal needs to be processed while it is being generated - one sample at a time. In this post, I am showing two different implementations of digital filters, that can be used in a real-time setting.

Applying digital filters in Python

Digital filters are an important tool in signal processing. The SciPy library provides functionality to design and apply different kinds of filters. It is designed for offline use and thus, however, not really suited for real-time applications. In the next post, I am highlighting how live versions of the SciPy filters are implemented in yarppg, a video-based heart rate measurement system. Before looking into the implementations, let’s discuss what digital filters can do and why they are so important in signal processing.

Extracting heartbeat signals from webcam video

MediaPipe update 2023 Please note that MediaPipe has seen major changes in 2023 and now offers a redesigned API. The code in this posts still works as of mediapipe==0.10.7. Check out this post for more details on the new API. With every heartbeat, the color of your skin changes slightly. While this effect is invisible to the human eye, a normal camera is able to pick up these tiny differences.