Railway safety has vastly improved for motor vehicles, but reducing the risk of collisions with pedestrians is much trickier.