Do your glasses get so dirty that it's visible in a webcam image before you clean them yourself? In typical lighting conditions, I don't think my lenses' smudges are visible until well above the threshold where I'd clean them myself.

Then improve the hardware so it can detect these smudges.

But why? It's easy to tell when you need to clean your glasses without special equipment. Unless I'm missing something, there doesn't seem to be a problem to be solved here.