1
$\begingroup$

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.

$\endgroup$

1 Answer 1

0
$\begingroup$

So the answer came to me, as answers are wont to do, in the shower: since we're trying to figure out overall direction here, instead of trying to figure out motion frame by frame, just compare the first and last detected positions of each object.

movement = first['left'] - last['left']
direction = 'right' if movement < 0 else 'left'
if abs(movement) < MOVEMENT_THRESHOLD:
  continue

The threshold can be used to remove incomplete/unclear paths, including U-turns where a person leaves the way they came (meaning the net movement is zero) or an object was only tracked for a few frames.

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.