It could be done with two motion sensors covering different areas. Depending on which is triggered first you can determine the direction of travel.
If there's a door you could have a door sensor and a motion sensor. If motion before door sensor triggered that indicates an exit (assuming there isn't other motion in range of the motion detector.
You could also use a camera and computer vision but that's more appropriate for a computer instead of an Arduino.