Fiddling with ML to mind my posture

I was a bit bored this afternoon and wanted to try getting a better posture. While a kinetic method would be most reliable and portable, it would be cumbersome and require some investment in equipment and a sort of harness or shirt clip. I figured it would also be unsightly, so I decided to target my sitting posture first.

While another kinetic method would be useful, like a pressure sensor or simple switch, it would require some wiring and maybe a remote power source if I like wheeling my chair back and forth. I also wouldn’t mind being able to use it at work until I can work remotely, and don’t really want to be modifying their chairs.

With those constraints in mind, I decided to try some sort of image analysis. I wondered if I could do simple colour recognition, but variations in lighting would cause the exposure and saturation of the webcam driver to shift in an attempt to keep me visible, so that was quick to rule out.

Next, I looked into ML models that were pretrained to recognise a face and eyes in portrait. I was hoping to use the position of my head to determine if I’d started slouching. Initial tests appeared promising, my head was recognised and after a calibration step it would reliably detect my height difference and start firing events when I dropped too low or stretched too high.

Unfortunately, I found several limitations in the dataset used to train this model. It was not trained on profile images, only sets where users are looking directly into the camera. It could not recognise me when I turned my head slightly to look at my second monitor, meaning I could slouch as none of my head is recognised. Another limitation were the limited haircuts supported - my hair came down my face far enough to obstruct one of my eyes or the shape of my forehead. When this occurred, detection would fail.

These two drawbacks caused me to look for an alternate solution. After a bit of rummaging, I found another blog where a user had spent time working on angle detection. His model would determine the face area and show you an estimated rotation. My efforts were halted by his code being locked behind a subscription newletter.

I considered training my own but at this point it was 3am, so I decided to give it a rest. Maybe I’ll pick up again in the future.