Object tracking explained: IDs, occlusion and re-identification

Object tracking gives each detected person or vehicle an ID and keeps it across frames. Occlusion breaks IDs; re-identification uses appearance to restore them.

By CloudOEngine.ai Engineering · · 12 min read

Object tracking takes the boxes a detector finds in each video frame and links them over time, so every person or vehicle carries one ID from the moment it appears until it leaves. Occlusion, when something blocks the view for a few frames, is the main reason IDs break or swap. Re-identification is the fix for longer gaps: it compares how an object looks as well as where it was, so a person who reappears can get their old ID back instead of a new one.

One person, two IDs

As an illustration, picture a camera above a supermarket entrance at 6pm. A woman with a red shopping bag walks in, gets ID 41, and passes behind a pillar for about two seconds. When she comes out on the other side, the detector finds her again without any trouble. The tracker, though, has already given up on ID 41, so she becomes ID 57. If the counting line sits just past the pillar, she can be counted once as 41 entering and again as 57.

Nothing in that story is a detection failure. The error came from the step in between, which decides that the box in this frame and the box in the last one are the same person. That step is tracking, and most of the double counts and odd dwell times you will find in a video analytics project start there.

Our guides to people counting with CCTV and video analytics accuracy cover the counting side. This article opens up the tracker itself: how it assigns IDs, why occlusion breaks them, and what re-identification can and cannot fix.

What a tracker does every frame

Most trackers used on CCTV today follow the "tracking by detection" pattern. A detector runs on each frame and returns boxes. The tracker never looks for people itself; it only decides which new box belongs to which existing track. For each frame it does four things.

It predicts. Every live track has a motion model, usually a Kalman filter, which estimates where the box should be in this frame given its last position and velocity. DeepSORT, for example, tracks the box centre, aspect ratio and height, plus their velocities, under a constant velocity assumption.

It scores every pairing. For each predicted track and each new detection it computes a cost: how much the boxes overlap (intersection over union, IoU), how far the detection is from the prediction, and in some trackers how different the two look.

It assigns. Given that grid of costs, an assignment algorithm (the Hungarian algorithm is the classic one) picks the set of pairings with the lowest total cost, so no detection is given to two tracks.

It updates. Matched tracks take their new box and the Kalman filter corrects itself. Unmatched detections may start new tracks. Unmatched tracks are marked as missed for this frame.

The 2016 SORT paper showed how far this simple loop goes. Its authors used only a Kalman filter and the Hungarian algorithm, reported accuracy comparable to the best online trackers of the time, and measured the tracker updating at 260 Hz, over 20 times faster than the others they compared against. They also found that detection quality was a key factor, with a change of detector improving tracking by up to 18.9%.

Every frameDetectboxes in this framePredictKalman: where nextMatchIoU + appearanceUpdatekeep, start, drop IDsnext frameThe life of one trackTentativefirst few framesConfirmedID is reportedLostno match, coastingDeletedbuffer ran outre-found in time: same ID keptDeleted too early: a new ID and a possible double count. Kept too long: a wrong match.
The per-frame loop on top, and the states a single track moves through below. Most identity errors happen at the Lost box: whether the track is re-found before its buffer runs out, and whether it is re-found by the right person.

The life of a track

The bottom row of that diagram is where the tuning decisions live, and they are easy to overlook because the defaults usually look fine on a demo clip.

A new detection that matches nothing does not get a public ID straight away. DeepSORT, for instance, classifies new tracks as tentative for their first three frames and deletes them if they fail to match in any of those frames. That filters out one-frame ghosts, such as a reflection in a glass door.

Once confirmed, the track reports its ID. When it stops matching, it is not deleted immediately. The tracker keeps predicting its position (coasting) and counts frames since the last match. DeepSORT deletes a track once that count passes a maximum age, and its authors evaluated with that maximum set to 30 frames. Ultralytics calls the same setting track_buffer, and its default ByteTrack configuration also sets it to 30. The comment next to that line in the configuration file says it plainly: a higher value handles occlusion, and increases the risk of ID switches.

The buffer is counted in frames, but occlusions happen in seconds. As an illustration, 30 frames is 1.2 seconds on a stream running at 25 frames per second. If someone lowers the analytics stream to 10 frames per second to save compute, the same 30 frames now cover 3 seconds, and the tracker will happily hold a lost track across a gap two and a half times longer than before, with more time for a different person to walk into its predicted position. Nobody changed the tracker. Changing the frame rate changed its behaviour.

So write the buffer down in seconds. Measure how long the typical occlusion lasts at your door, aisle or gate (a pillar, a display stand, a forklift passing in front of a worker), then convert to frames at the rate you actually process.

Why occlusion breaks IDs

Short occlusions are mostly a motion problem. While a person is hidden, the Kalman filter keeps moving their predicted box in a straight line at the last known speed. If they keep walking steadily, the prediction lands close to where they reappear and the IoU match succeeds. If they stop to look at a shelf, turn, or speed up, the prediction drifts away from them, the overlap drops below the matching threshold, and when they reappear they look like a stranger to a motion-only tracker.

DeepSORT's authors describe exactly this weakness in SORT: its association was only accurate when the uncertainty in the motion estimate was low, which led to a high number of identity switches. Their extension added an appearance descriptor. A small neural network turns each detected box into a vector that describes how the person looks, trained on a person re-identification dataset of over 1,100,000 images of 1,261 pedestrians. Each track keeps a gallery of its last 100 appearance descriptors, and a new detection is compared against that gallery as well as against the motion prediction.

The result on the MOT16 benchmark was a drop in identity switches from 1,423 to 781 compared with SORT run on the same detections, a decrease of about 45%. The cost was speed: the implementation ran at about 20 Hz, with roughly half the time spent computing the appearance features. The paper also reports that track fragmentation rose slightly, because the tracker was now holding identities through occlusions and misses rather than starting fresh ones. That is the trade in one line: fewer new IDs, more chances that a held ID attaches to the wrong thing.

Partial occlusion causes a different failure. A person half hidden behind a trolley still gets detected, but with a low confidence score, and many pipelines throw low-score boxes away before the tracker sees them. The ByteTrack authors point out that discarding low-score detections, such as occluded objects, loses real people and fragments trajectories. Their method matches high-score boxes first, then tries the low-score boxes against the tracks still unmatched, keeping the ones that continue a real track and dropping background. Applied to nine existing trackers, it improved the IDF1 identity score by between 1 and 10 points. In Ultralytics' configuration you can see this as two thresholds, track_high_thresh for the first pass and track_low_thresh below which detections are ignored.

Each of these settings trades one error for another, and a single tracker gives no signal about which way it guessed on a given crossing. This is why CloudOEngine's Vision AI counts with two independent trackers and sends the cases where they disagree to a human review queue, where your staff check the clip and decide.

Re-identification: same camera, other camera

Re-identification (re-ID) is the appearance part taken further. Instead of helping across a two-second gap, it tries to match a person after a long gap, when motion tells you nothing useful. The research field usually defines person re-ID as retrieving a person of interest across multiple non-overlapping cameras. A 2020 survey by Ye and colleagues separates the closed-world setting, where most benchmark progress happened under research assumptions, from the open-world setting, which is closer to real deployments and harder, and notes that closed-world performance has reached a plateau.

In practice there are three situations, and they need different tools.

Gap What still works Main risk Usual fix
A few frames in one camera Motion prediction and box overlap Prediction drifts if the person stops or turns Longer buffer, low-score detections (ByteTrack)
Several seconds in one camera Appearance, with position as a sanity check Look-alikes near the predicted spot Appearance gallery per track, with a minimum overlap or distance gate
Different cameras Appearance only, plus camera layout and timing Uniforms, lighting and angle changes Dedicated re-ID model and handover rules per camera pair

The middle row is where most single-camera projects should stop. Ultralytics exposes it as an option: with_reid turns on appearance matching "for better tracking across occlusions", it is off by default, and two thresholds guard it. proximity_thresh requires a minimum IoU before an appearance match is even considered, and appearance_thresh sets the minimum similarity. I like that design because it refuses to let appearance alone pull an ID across the frame to someone who happens to wear a similar shirt.

Cross-camera re-ID is a bigger step. Lighting and viewing angle change between cameras, and in many workplaces appearance is deliberately uniform. As an illustration, on a factory floor where everyone wears the same blue overall and white helmet, an appearance model has very little to work with, and a cross-camera match is close to a guess.

There is also a question to settle before any engineering. Linking one person across many cameras builds a movement history of an identifiable individual, which is a different thing from counting how many people came through a door. If your use case is footfall or occupancy, you probably do not need it. If you do, involve whoever handles data protection early, and read our overview of AI governance under India's DPDP Act. This is not legal advice.

Measuring identity errors

The metric you choose decides which errors you see. MOTA, the long-standing benchmark score, combines missed detections, false positives and identity switches into one number. The DeepSORT paper shows the side effect: its tracker had the fewest identity switches of the online methods it compared against, yet its authors note that its MOTA was held back mostly by false positives. Detection errors can swamp identity errors in that one number.

IDF1, from Ristani and colleagues' 2016 paper, was designed to measure identity directly. It first matches each true trajectory to the computed trajectory that explains most of it, then counts the frames where the tracker is right about who is where. Their example makes the difference clear: if one person's path is split into two fragments, or into eight, older event-based measures charge one fragmentation error in the first case and seven in the second, while IDF1 charges both by the share of frames that were wrongly identified. HOTA, from Luiten and colleagues, argues that earlier metrics overemphasise either detection or association, and balances detection, association and localisation in one score that can be broken down by error type.

For an operational system, none of these replaces checking the outcome you care about. If the output is a count, the useful test is to match each counted crossing to a crossing a person marked on the same footage, as described in our video analytics accuracy guide. Benchmark scores tell you which tracker to try first. Your own footage tells you whether it works. When CloudOEngine's Vision AI finalises a count, it ships with a published accuracy report and every counted crossing is shown, so anyone who doubts a number can replay the crossings behind it.

Tuning a tracker on your own footage

If I were setting up tracking on a new site, this is the order I would work in:

  1. Record 20 to 30 minutes from each camera at the busiest time of day, at the resolution and frame rate you will actually process.
  2. Watch it and note every occlusion: what causes it and how many seconds it lasts. Pillars, display stands, groups walking together and vehicles crossing in front of people are the usual ones.
  3. Fix the detector first. Run it alone and look for boxes that flicker in and out on visible people. If they do, no tracker setting will save the IDs.
  4. Set the track buffer from step 2 in seconds, then convert it to frames at your real processing rate.
  5. Turn on low-score association and, if occlusions are longer than a second or two, appearance matching with a proximity gate.
  6. Have someone mark ID switches on a few clips by hand, especially near counting lines, and compare settings against those marks rather than against how smooth the tracks look.
  7. Re-run the same clips whenever the camera, the stream settings or the frame rate change.

Step 7 is the one that gets skipped, and a lower-bitrate stream changes detection quality as much as a frame rate change alters every buffer. Our article on low-bitrate CCTV and AI detection covers what compression does to the boxes the tracker depends on.

How CloudOEngine helps

CloudOEngine is one platform and one console for connecting data (databases, files and camera streams), building pipelines, and running an AI runtime with an LLM gateway, agents with tool access and RAG, alongside Vision AI and live video. All of it sits under one permission model and one audit trail, so the people who can see a camera feed or a count are governed the same way as those who can query a database.

For counting, Vision AI runs two independent trackers on the same footage rather than trusting one. Where they agree, the crossing is counted. Where they disagree, which is often exactly the occlusions, look-alikes and lost tracks described above, the case goes to a human review queue where your own staff check it and decide. A finalised count ships with a published accuracy report, and every counted crossing is shown, so a store or site manager can replay the evidence behind any number instead of taking it on trust.

Governance is included, not sold separately: tenant isolation, role-based access, audit logs and per-tenant encrypted secrets apply to video as they do to every other source.

CloudOEngine is built in Bengaluru, India.

Book a demo or see Vision AI.

Frequently asked questions

What is multi-object tracking in video analytics?

Multi-object tracking takes the boxes a detector finds in each frame and links them over time, so the same person or vehicle keeps one ID while it is in view. Counting, dwell time and line crossing all depend on those IDs rather than on single frames.

What is an ID switch?

An ID switch is when the tracker changes the identity it reports for one real object, for example after a person walks behind a pillar and comes back with a new number, or when two people crossing paths swap numbers. In counting, an ID switch near the counting line can turn one person into two.

What is the difference between tracking and re-identification?

Tracking links an object from one frame to the next, mostly using where it was and how it was moving. Re-identification matches by appearance, so it can recognise the same person after a long gap in one camera or in a different camera, where position no longer helps.

How long should a tracker keep a lost track alive?

Long enough to cover the typical occlusion in your scene, measured in seconds and then converted to frames at your real frame rate. Ultralytics ships ByteTrack with a 30-frame buffer by default, which is 1.2 seconds at 25 fps but 3 seconds at 10 fps, and longer buffers also raise the risk of a wrong match.

Which metric shows identity errors best?

IDF1 measures the share of frames in which the tracker is correct about who is where, so it punishes identity errors directly. MOTA is dominated by missed and false detections, and HOTA balances detection, association and localisation in one score.

Sources

  1. Bewley et al.: Simple Online and Realtime Tracking (SORT), arXiv 1602.00763
  2. Wojke, Bewley and Paulus: Simple Online and Realtime Tracking with a Deep Association Metric (DeepSORT), arXiv 1703.07402
  3. Zhang et al.: ByteTrack: Multi-Object Tracking by Associating Every Detection Box, arXiv 2110.06864
  4. Ristani et al.: Performance Measures and a Data Set for Multi-Target, Multi-Camera Tracking, arXiv 1609.01775
  5. Luiten et al.: HOTA: A Higher Order Metric for Evaluating Multi-Object Tracking, arXiv 2009.07736
  6. Ye et al.: Deep Learning for Person Re-identification: A Survey and Outlook, arXiv 2001.04193
  7. Ultralytics docs: Multi-object tracking (track mode)
  8. Ultralytics: default ByteTrack tracker configuration (bytetrack.yaml)

#object tracking #re-identification #occlusion #video analytics #computer vision