The interview problem

Practice prompt

Design single-camera tracking that counts objects crossing a line without counting the same object every frame.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume anonymous warehouse packages, one camera and no identity recognition. Detect boxes, predict motion, associate detections to active tracks using gated geometry and appearance, and keep a bounded lost-track state. Count a crossing only when a track moves between stable sides of the line. Train and evaluate on complete video sequences, split by conveyor setup. Keep detection quality, identity switches and crossing count errors as separate metrics.

2. Trace the design or derivation

Detect
  → predict motion
  → gate matches
  → update tracks
  → count stable crossing

Maintain a per-track crossing state such as upstream, on-line and downstream, with hysteresis around the boundary. A package vibrating on the line should not generate many crossings. If reverse movement is meaningful, define whether it cancels a prior net count or creates a separate reverse-flow event.

3. Calculate the example

A package visible for 40 frames should produce one crossing. If one occlusion splits its trajectory into two IDs, a naive new-track counter emits two; a side-transition counter can avoid this if both fragments never independently cross.

4. Failure cases and trade-offs

Long occlusions make identity uncertain; do not force a match just to preserve IDs. Appearance helps similar trajectories but can fail for identical packages. Extending track lifetime improves recovery yet increases false reassociation risk. Report uncertainty when tracks disappear on the counting line.

5. Validation, follow-ups and self-review

Test stopped conveyors, reversals and two packages touching. Follow-up: how would a second camera change association? Self-review: define the count event precisely and distinguish object detection from temporal identity.

Sources and related practice

Technical reference: arxiv.org — Object detection from images; counting, tracking and road workflows are original applications, not paper benchmark claims.

Source publication/update: Submitted June 8, 2015; revised May 9, 2016. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Count products on warehouse shelves; Solve one-to-one matching without greedy mistakes.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.