If I remember correctly, some types of pedestrian crossings in the UK actually use sensors to automatically detect people waiting near the lights (and also detect if they're still around, or have actually crossed/otherwise disappeared before the pedestrian phase [1]).
If you want to do more than that, i.e. detect pedestrians before they actually reach the crossing, the problem is that pedestrians don't have turning lanes, so it's hard to tell which way people approaching the crossing actually want to turn.
[1] If I'm not severely misremembering things, one thing I like about UK traffic regulations is that it's not actually illegal to cross against a red light as a pedestrian if you're not obstructing anybody. Obviously if there's an accident you're going to be liable if you crossed against a red light, but if the road is clear and nothing happens you cannot be fined.