One could use the webcam for this, although I'm not sure how that affects battery life. Also personally it would creep me out to have the cam enabled permanently.
There are other implementations of this concept that have been around for years that are a bit more practical for most people, like the ones that use your smartphone's proximity to the desktop/laptop as the locking trigger.