Something you could do would be IR LEDs and an IR camera, where the LEDs are only reflected on the shiny keys when they're pressed due to the angle.
Yes, there are many use cases that I have in mind where this is a must. In fact, if I can't crack it then it's a useless project (other than that I will learn from it).
There are all kinds of devices that could give you midi inputs (such as the 'Piano Bar', sadly discontinued), but that's the easy way out. After all, you could also simply use a MIDI enabled keyboard. But I want it to work with a real piano, as well as possibly other instruments.
The best software for this at the moment is Anthemscore.
I'm quite sure it is possible but it would still require a lot of set-up. The microphone is such a temptingly simple target that it makes sense to pursue that one first.