You know, I had a similar idea a few years ago. Initial idea was to prevent eye strain. You can check it out: http://viewaide.com/
Here I analyze more than slouching (distance to the monitor and even blink rate). It was written in C++ in my students years and code style is a shame on me. But if someone is interested, I can upload this on Github.