If you are reading this you are most likely sitting in front of a computer of some sort, maybe even slouching into the chair. Often we don’t care about our posture which can result in back pain and worse. This application is supposed to solve this problem using a webcam and facial recognition. If you get too close to the screen or start slouching it will open a popup window as a reminder.
The app was created using Processing (.org) and is based on the OpenCV computer vision library. I programmed this three years ago and added a few features since then that I wanted to share.
Another on of my posture monitor projects again involves an Attiny85. While my previous sensors were either fixed to a chair or desk, this time I wanted to create a wearable version, that would allow for free movement. An ADXL335 is used to measure the angle of the chest to determine the posture. A vibrating motor gives haptic feedback if the posture is bad. All the parts including a coin cell to power the electronics fit into a custom 3D printed case.
One of the first projects on my old blog is a simple posture sensor based on an Attiny85 and an ultrasonic distance sensor. The way it works is very similar to the webcam software. It is attached to a chair and measure the distance to the back of a person's head. If the person slouches, the distance increases and piezo buzzer starts beeping.
The software is based on OpenCV, more specifically the opencv library for Processing. OpenCV contains all sorts of tools for image processing, one of these being face tracking. The image of the webcam is being searched for a face. The height and the size (~distance) of the detected face is compared to a set threshold. If the thresholds are exceeded for more than two seconds the alarm will sound and then silence after a few seconds. If the user gets up from his chair or the face is not visible the alarm will not be triggered. The alarm itself is just the Windows error sound. The user interface consists of the live image in the background. Three buttons are for setting up the limit values and for pausing the alarm.
There are different ways to detect if someone is sitting or standing with a bad posture. Different companies are trying to detect if you are slouching and remind you to sit/stand straight. One of these is Lumo (https://www.lumobodytech.com/) which is using wearable monitors to the angle of your spine based on an accelerometer/gyro. An entirely different approach is using face tracking based on a regular webcam. Besides the webcam itself, no additional hardware is necessary.
Based on this example, I took the height and size of the recognized face to determine of someone is slouching or sitting too close to the monitor. You sit straight, then calibrate the software. If your face moves below this threshold, an alarm pops up over the webcam image. The project got featured on hackaday and around that time someone asked me to make an improved version. This second version includes an additional popup-window, so the program can be minimized.
If you want to try out the software, all the necessary files and the source code is available on github: