Multi-Object Tracking with Ultralytics YOLO11

Muhammad Moin · Beginner ·👁️ Computer Vision ·1y ago
Skills: CV Basics80%

Key Takeaways

Performs Multi-Object Tracking using Ultralytics YOLO11

Full Transcript

in this video tutorial we will look at multi-object tracking with ultral litics Yow in object tracking we assign a unique ID to each of the detected object and then we track that detected object throughout the entire video frames we will also plot the movement of detected object across multiple video frames by drawing the trails which in through which we can see what pattern the object this following the applications of object tracking are Limitless from security and surveillance to Real Time Sports analysis in this tutorial for object D for object detection I will be using ultral litics yo 11 model and for object tracking I will also use the tics package tics package currently Sports uh two object uh tracking algorithms one is board sort and other is by drag So currently uh the allytics package support two object tracking algorithm although there are other object tracking algorithms available as well like deep sword sword and others as well but currently the tics package uh sport two object tracking algorithm which I told you one is H sort and other is by drag so we will be using uh tics package to integrate object tracking with our object detection uh uh model so let's get started with this here you can see the demo is being played on your screen as well in this uh demo you can see that uh for each of the detected object we have assigned a unique ID like 1 3 9 10 and you can see that we also we are also uh checking the uh movement of the detected object by drawing that Trails which is telling us what path the object is being uh following okay so this is a quick demo and let's get started with this over here so first of all I will uh start writing the down the code from scratch and U then I will show you how you can integrate object tracking with your object detection algorithm so but before I go ahead uh you can check this documentation by Alter etics like how you can uh perform multiobject tracking with altic yolo so we will following this documentation uh in this complete tutorial so you can also check out this documentation and you just need to search on Google by m tracking with altic yolo and you will just find the first link and you can just click that link and you will be able to open this documentation so let's start writing down the Cod so over here you can see I have just created a project in P jum over here and you can see I have multiple video files over here and first of all I will just create a requirements. PhD file we require the tics package along with tics many other packages can installed as well like open python M blot Li numi cbond so we will install install IB R requirements. PX so now I'm just installing the AL package because in my requirements. txd file I have only mentioned the altic package uh spellings are all for the requirements let me that's on this so if you have uh mentioned any other package in this requirements. TD file this will also we get downloaded with the ultral litic package as well currently we only require tics package along with ultr litics package like Sky to open CV python many other packages get installed as well like you can see met BL open CV python over here so numai so you can see over here many of the packages are been getting installed P so let's try uh create our newp file over here we write object tracking doy so in the step number one we will import on the reir like so I'll dra ltic in four YOLO we will lower the YOLO 11 model I model is equal to YOLO and we want the YOLO 11 Nano model YOLO 11 comes with five different model YOLO 11 Nano is the fastest but it this the least accurate among other YOLO 11 models the first see tracking with all rightor or S okay so if you just check out the documentation over here uh you will find that the default tror is board sort okay so if uh you don't Define the tracker over here like you write model DR and don't Define the tracker over here let me just Zo zo in okay and so if you write model track but you don't Define the tractor over here it will use that default trackon which is B sort so tics support the following tracking algorithm B sort and B braack uh so you can enable uh any of these tracking algorithms like either bord or B braack by by passing the bort. yml file or by. yml file so by passing the rangement yml configuration you can activate any of the tracker okay so if you want to check uh the information like uh on the alternative Striker base like gr you can see it's for two trackers B swort and pip track okay so let's move for the for all right Reser model dot so if I want to do object detection I don't need to write anything I just need to go over here and write the source in which I need to pass the video path but if you want to add tracking you just need to write track over here and then you just need to define the source file like input file over here so I just need to go to the resources folder then I just need to go the videos folder and I I can use 7 if I want to show this uh video I can write show is equal to true and if you want to save the output video uh you can write save is equal to true so shortly our packages will be getting installed like currently it's doing indexing so this will not take very much time so let's wait for this to finish and then I will just try implement this boort so now you can see currently we are using default Breer Port sort because I have not defined any tracker over here okay so let's wa for the packages and now you can see that finally the packages package installation is being done and now let's run this script over here okay so the indexing is almost completed uh let's wait for a few second uh the indexing is being done so this will not take very much time okay let's run the object so it takes around 5 to six minutes for the allytics package get installed because with allytics many other packages also get installed so this Tak some time okay so first of all it will download the Yello 11 Nano model automatically downloads you don't need to go to the GitHub repository and specifically download the Y 11 Nano model okay okay now you can see over here okay so we are just getting issue no module Name Lab okay so we can just write over here uh we also need to install the lab package as well um Al should include in their installation like we don't need to install specifically so now you can see I'm downloading installing the lab package over here and you can see Yol 11 Nan model is being downloaded so this installation will take two seconds more as well so let's wait for it to get finish uh we can ignore this so uh let me just J hopefully should run now and next see or nothing it will perform an out upate right here okay so here you can see we have the reserv now you can see that uh ID is equal to one and here we are deducting the car so okay but we are not able to assign the we are not able to do the detections over here okay so now you can see as the object comes near we are able to do the detections now you can see that each of detected object is being assigned a unique ID now it looks pretty good yeah so now you can see that each of directed object is being randomly assigned an ID okay so if you use currently I'm using YOLO 11 Nano model but if you use uh other models like YOLO 11 medium or YOLO 11 x which have a high accuracy rate so you will see that detection is Will further in currently I'm running it on my CPU machine I don't have a GPU so therefore I'm graphing YOLO 11 Nano model because it is the fastest among YOLO 11 model but it is least accurate okay so now you over here you can see that we are able to Direction and we are able to assign a unique ID to each of the detected object over here okay so now you can see this is WR detection over here I I'm using 11 Nano so therefore there are some false positives over here as well but uh this is what we do in object breacking like you can see we are signing a unique ID each of the directed check okay and to stop this I will just click pause button and it will stop okay so the next thing which we can do is now we will see how we can do tracking with by track okay so we will just be fine result is equal to model do track over here course is equal to let's use some other video I just need to go inside the resources folder then videos uh let's use video .4 I want to see the output and you can see over here uh our output is being saved over here for the previous uh run okay isal and we want to use by track. yml and you uh like for the prediction in Yolo V8 model we have uh different arguments similarly we have Arguments for the tracking as well like we can set the quent fual to 0.20 we can set the non expression I do 0.5 you can adjust these parameters we can make it so let's run this now okay I made a mistake I just need to commment this over here we have the output now you can see over here uh we are able to take the person over here in this video and you can see that uh with each person we have assigned a unique ID like 7 6 3 2 uh 1 like you can see we are not able to take these persons but if you use uh other YOLO 11 models currently I'm using Y 11 Nano model but if you use models other y 11 models which have a high accuracy rate um then it will be able to protect these persons over here as well okay and but in this tutorial we are focusing on object tracking basically object tracking we assign a un B to each of the detected object like you can see over here we have assigned a unique ID add to each detected object and then we can track that detected object uh throughout the entire video frames okay so we are done with this and that works pretty fine okay so now first of all I will just inment all this okay so you can uncomment this and run this okay so now I will just write a python script using open CP Python and uh YOLO 11 to run object tracking on video frames or you can also run on the live webcam feed as well okay so let's add a separ that so we will write up python script using open CV Python and yo 11 run object tracking on video frames and okay so let's get started with this as well so first of all we import on the required Library import CV2 from altic import YOLO lower the YOLO 11 mod right model isal to YOLO YOLO 11 Nano BT next we will create a video capture object right CV2 video capture we just need to go into the res sources folder then we just need to go to the videos and we can use video 7 or uh we can just use video 5 let's use some other video then you will gr through b frames I write while through red on frame is Cap read so if we have able to read the video because that returns a boan cre so if returns a that returns a Boolean cre that is able to read a video then uh we will run Yow 11 tracking on the video frames so we'll write results is equal to model we have the input frame and we will set argument assistant isal to true so this argument tells the tracker that it should expect uh tracks from the previous frame or image in the current frame so persistant is equal to two tells the tracker that it should expect tracks from the previous frame into the current frame okay on next we will visualize the on frame we have an dat frame is equal to and thir Z Lo next we will display the an we can write the name of the window as youring so now uh in this window we will show so object tracking integrated with our object detection all right if c. key so we will add 1 millisecond delay between the consecutive frames and if the users press q key then the loop will break we can add the command break the L if q key is press simp and if it's unable to read the video frame then it will break as well and then we will release all the frames and we will destroy on the Windows as well so let's run this up now so now over here you can see that we are able to integrate object tracking like you can see that for each of the reected object we are able to assign a unique ID like one with this person six with this bicycle and and I ate with this bicycle and the results look quite good like you can see with traffic lights we are also able to assign a unique ID over here okay so the results look quite promising to me okay yeah the results look quite good like we are able to assign a unique ID with each of the Reed object like 17 15 8 3 1 14 okay so if I press D the loop will break that it so the next thing we can do is um now we'll uh see what uh part the object is following so we draw that fil or we can write create another python script over here object tracking Dash trails so we plotting tracks for time we will plot the moment of red object across multiple video frames first of all I will import all the required liaries uh so uh we will be saving the center point of each of the Bing box uh into our dictionary and then using that center point we will be drawing lines okay so we will be said saving the center point of the bonding box in each of the frame in our dictionary and using that Center Point then we will draw the lines so now we will load the YOLO 11 model then we will create the video capture check we just need to go inside the resources then we just need to go to the videos and then we can use video 5. MP4 so we will store that track hist spray into our dictionary then we will move through the radio frames app. read so if we are able to read the video then they run your 11 backing Ram right LE isal model TR here we have the source which is frame now we need to get the bounding box coordinates and the R ID boxes is equal to because this will contain the bonding box coordinates for all objects in the frame and then we'll look through this so we can write result zero we require this a center coordinate then we'll also requ the track ID so we'll get the track IDs for all the objects in love frame so similarly in the previous do by file we WR result on the frame as well and and this Frame so I can display the annotated frame as well so then we can write if CB2 dot with ke one there is a 1 millisecond delay between the projective frames and if the press the W key I missed one thing over here then the great so now I will release all the frame and destroy all the windows as well so let me just run this so now currently you can see that we are able to do Implement object tracking but uh we are not able to draw the tracks we show the path the object is following so I just press the W key it will close uh so we need to plot the tracks for this I will write the code over here so now we will look through the center coordinates and the track ID so I will just write box for my track I and Si there we have the boxes or Dr ID so here we have created a default dictionary by the variable practi hisory now it's time to use this in this track ID we have the object IDs for all the objects in the frame uh so with that each track ID we will save the center point of the bonding box and we will then connect the center point of the bonding box for the all the frames and then we will draw the lines which tell us the path the object is following so we uh need to retain that points or Center points for the 30 frames okay so we write 10 track 30 so we will retain the center points for the 30 frames so if you increase this value to 60 or 90 uh the the tracking Trail line will increase okay I will just show you as well now we're going draw the tracking lines so using c. poing lines we will draw the trails or the lines here we have the information of the center points and the thickness will be 10 okay so that works pretty fine let's R this up now uh we can just ose video uh it so let's see how does it works so the color of these lines will be white because we have just set the color to white you can just change to color any other color as well okay so now you can see in the white we have the rails over here so we chose the path the object is forming okay so now you can see over here we have the trails over here uh so let me just show you with other video video and we can just change the color to look next on this now okay okay so again weord the error so yeah so how how we can deal with this we can write xard zero ID is not no okay so now hopefully this will work out like see so now over here you can see that we are drawing the TRS with uh blue color over here okay okay so now you can see that these trails are telling us the pattern the object is following okay so now you can see over here we are drawing the trails over there as well or if I just press the W key this will close and if I just trite 90 over here let me show what does it Mak so if I just write 90 over here the length of this three when further increase of this one you can see that like huge B see this is telling the part uh the object is been following now you can see that the length has so much increase okay so this is how it makes impact but 30 is the ideal value okay so now we have seen that how we can plot the movement of object how we can integrate object tracking now we will inclement multi- threading multi threaded tracking so multi- thread Ed tracking provide us the capability to run object tracking on multiple video streams or multiple live cam webcam feeds as well okay so we can create another dot by pile multi tracking provides capability to run check tracking on multiple video things okay so first we will import on the libraries import ring import CV2 from Ultra litics import your so next we need to uh Define model names like what different models we use need to use in the multiple video streams and and uh R your sources you can also Define the webcam sources as well we are use y inam Nano model and we will also use y 11 Nano segmentation model as well we have SL do just need to go inside the resources then they we need to go the videos and first we'll run video 7. MP4 then we have sources videos radio. MP4 okay so now we will run YOLO 11 tracker in its on track for concr proc sing so we'll create a function red we just need to pass the model name and the file name in the input run 11 right in it on thread for conent so we'll pass the model name to the wa here then we write result model. back because we need Brey then in the source over here we have the file name we need to save the output video then when you need uh in the documentation they have said stream is equal to true but this doesn't show the output video so we just need to write show is equal to true then we'll look through the results now create and start drag thread we now create and start record threads using our for Loop so now we'll Lop through the video files and the model names so the arguments will be modern L and the video five so now we will run YOLO tracker in its one thread for conrant processing I will show you in the output how this works let's start this up now now before it completes for example if any video completes it will wait for all the tracker threats to finish now we clean up and close all video than now we clean up and close all windows so we C2 destroy all windows so this is how it works uh let's run this and see if it works so we have we 11 Nano model but we don't have the segmentation model so it's downloading and let's so this is our first video and and here is our second radio you can see over here we are able to that uh Implement multi threading so using multi threading uh it provides us the capability to run object tracking on multiple video streams like you can see over here on one side I'm implementing object tracking with the segmentation model and on the other side on the left hand side I'm implementing object tracking with the object detection model okay so now you can see that the results look pretty good like you can clearly see over here uh the result look quite promising to me as well okay so now um using multi- threading we are able to implement object tracking so the results look quite promising so now we are able to implement object tracking on multiple video streams as well so multi tracking provides a stock capability to run object tracking on multiple video streams which you can clearly see over here and over here you can see that uh we are doing congr processing we are running video 7 and video eight uh in parallel over here you can also run our live webcam feeds like if you have multiple feeds coming you can run it on multiple feeds as well and you can see this is what we call concr processing like we are running video 7 and video eight concretly at the same time okay okay so this is how it works and using multiple threading tracking uh we have run object tracking on multiple video streams uh that's all from this tutorial thank you for watching

Original Description

In this video 📝, you will learn how to perform Multi-Object Tracking using Ultralytics YOLO. In object tracking, we assign a unique ID to each detected object and track that object throughout the entire video frames. For object detection, we will use the Ultralytics YOLOv11 model, and for object tracking, we will utilize the Ultralytics package, which supports two object tracking algorithms: BoT-SORT and ByteTrack. Additionally, we will demonstrate multithreaded tracking, enabling the capability to run object tracking on multiple video streams simultaneously. *Github Repo* https://github.com/MuhammadMoinFaisal/Multi-Object-Tracking-Ultralytics-YOLO11.git _______________________________________________________________ *🧑🏻‍💻 My AI and Computer Vision Courses⭐* *📗Build AI Agents with LangChain v1: Deep Agents & Tools 2026 (13$)* https://www.udemy.com/course/build-ai-agents-with-langchain-v1-deep-agents-tools-2026/?couponCode=PROMOTION13DOLLARS *📗YOLO26 Bootcamp: Real-Time Detection, Segmentation & Pose (13$)* https://www.udemy.com/course/yolo26-bootcamp-real-time-detection-segmentation-pose/?couponCode=PROMOTION13DOLLARS *📘Hands-On RAG Bootcamp: Build Apps with LangGraph & LangChain (13$)* https://www.udemy.com/course/hands-on-rag-bootcamp-build-apps-with-langgraph-langchain/?couponCode=PROMOTION13DOLLARS *📙Complete Computer Vision Bootcamp: YOLO to Multimodal AI (13$)* https://www.udemy.com/course/complete-computer-vision-bootcamp-yolo-to-multimodal-ai/?couponCode=PROMOTIONJUNE *📚 Generative AI, LLM Apps & AI Agents Masterclass 2026 (13$)* https://www.udemy.com/course/ai-agents-with-n8n-automate-anything-with-no-code/?couponCode=PROMOTIONJUNE *📘 YOLOv12 & YOLO26: Custom Object Detection & Web Apps 2026 (13$)* https://www.udemy.com/course/yolov12-custom-object-detection-tracking-webapps/?couponCode=PROMOTIONJUNE *📙 Modern Computer Vision with OpenCV 2026 (13$)* https://www.udemy.com/course/modern-computer-vision-with-opencv/?couponCode=PROMOTIONJUN
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

Up next
9-Phase Computer Vision Roadmap 2026 | AI & Deep Learning | #shorts
SCALER
Watch →