How to know opponent's Command Center energy?

I’ve always thought Dark Templars are useless against Terran due to their scanner. However, if there was a way to visually know their energy level, then you could attack with DTs when they don’t have sufficient energy for scanner.