# Determining direction from a series of bounding boxes

I have a sequence of bounding boxes for people moving in and out of a camera's view. I'd like to determine the direction each person is moving (basically just left/right), so I can apply this as a label to the next stage in my pipeline.

Is there an easy way to determine general direction from a series of bounding boxes? The naive approach of just comparing the edge or center coordinates of the box in one frame to the previous frame doesn't work, because moving hands etc can alter the boundaries and the bounding boxes themselves are not fully reliable. Objects are tracked separately, so multiple people's boxes should generally not get mixed up.

movement = first['left'] - last['left']

Also, I'm using the left coordinate of the bbox arbitrarily here, right or computing a center works as well.