Object tracking basics: following the same object across frames
Atlasbot · 18/8/2026 · 11 min read
Object Detection (the previous article) answered "what and where is this frame" — but running independent detection on each frame does not tell if the object in this frame is the same object as the previous frame. That's the problem Object Tracking solves: assign an ID to each object and track that ID throughout the video.
Key concepts
Running independent detection on each frame has two problems: computational resource consumption (the detection model is often much heavier than the tracking algorithm), and unknown motion — for example it is impossible to calculate which direction the object is moving, fast or slow, if each frame is considered as a completely new object.
How it works
The most common way is a combination: running detection to find an object at some frame, then using a lighter tracking algorithm (such as based on predicted location, image characteristics, or Kalman filter) to "follow" that object at subsequent frames without running full detection every time — only running detection periodically or when tracking loses the object.
from ultralytics import YOLO
model = YOLO("yolov8n.pt")
# .track () instead of.predict () — automatically assigns and maintains ID throughout the video
results = model.track(source="video.mp4", persist=True)
for r in results:
for box in r.boxes:
track_id = box.id # The only ID for this object, kept constant through the frames
print(f"ID {track_id}: {box.cls} tại {box.xyxy}")
Technical details
Formulas
Kalman filter (which learned the prediction-update principle at EKF, Robotics Fundamentals) is a core component of many tracking algorithms. — predict the object's position at the next frame based on the estimated velocity:
Predicted_position(t+1) = Position(t) + Estimated_velocity(t) × Δt
Example: object at (100, 150) in frame t, estimated velocity (5, 2) px/frame
Predicted_position(t+1) = (100+5, 150+2) = (105, 152)
When detection runs again, match the newly detected box to this predicted position
(using distance/IoU, covered in Basic object detection) to determine
whether it is the same object (keep its ID) or a new object
Parameters
| Strategy | frequency run full detection | Calculation costs |
|---|---|---|
| Detection per frame | 100% Frame | Highest |
| Periodic detection + light tracking between times | E.g.: every 5 frames. | Much lower |
| Pure tracking (no redetection) | First time only | Low, but easy to lose track of. |
Practical applications
With AMR, tracking is useful when it is necessary to track a specific person (the "person following"), count the number of objects passing through an area without coincidence, or predict the direction of movement of a dynamic obstacle to avoid it sooner rather than reacting only when the obstacle is close to the — correct application mentioned in the Navigation Layer in AMR, where the local costmap needs continuous updating according to the dynamic obstacle.
Practical example
def du_doan_vi_tri(vi_tri_hien_tai, van_toc, dt=1.0):
return (vi_tri_hien_tai[0] + van_toc[0]*dt, vi_tri_hien_tai[1] + van_toc[1]*dt)
# Track 1 person across multiple frames
vi_tri_lich_su = [(100, 150), (105, 152), (110, 154)]
# Estimate velocity from the 2 most recent frames
vx = vi_tri_lich_su[-1][0] - vi_tri_lich_su[-2][0]
vy = vi_tri_lich_su[-1][1] - vi_tri_lich_su[-2][1]
vi_tri_du_doan = du_doan_vi_tri(vi_tri_lich_su[-1], (vx, vy))
print(f"Vi tri du doan khung hinh tiep theo: {vi_tri_du_doan}")
Output:
Vi tri du doan khung hinh tiep theo: (115.0, 156.0)
When a new frame arrives, match the actual detection position to this prediction
(using Euclidean distance or IoU) to confirm the same ID, without running
the entire expensive detection model on every frame
Common mistakes
- Full detection of each frame when not needed — as the Parameter table, consumes incommensurate computing resources, especially on limited embedded hardware.
- Novel tracing without periodic detection over long periods of time— is prone to "drift" from the real object when there is interference or the object changes direction abruptly, requiring periodic re-detection for correction.
- Without dealing with the loss of the— trail when the object is temporarily obscured and then reappears, a simple tracking algorithm can assign a new ID instead of recognizing it as the same object.
- Using velocity estimates from too few historical frames — estimating the velocity from just 2 frames is much more diffuse than the average over many recent frames.
Conclusion
Object Tracking extends Object Detection from "an individual frame-by-frame identification" to "continuous time-to-event tracking" — which combines periodic detection with location prediction (typically via Kalman filter) which significantly reduces computational cost compared to running all-frame detection. This is the basis for more complex robot behaviors such as following people or predicting obstacle motion. The last article in this column puts YOLO into a complete ROS2 pipeline.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.