modes/track/ #7906
Replies: 139 comments 343 replies
-
Can I run two models simultaneously in one video? I want that two models will works simultaneously with cumulative results? Is it possible? Please let me know. Thanks in advance!! |
Beta Was this translation helpful? Give feedback.
-
Hi, First of all, I have been loving working with Yolov8. Great tool! However, I have been having difficulties with a certain task. I want to use model.track on videos that I have, and then use save_crop = True, but save with a naming convention where I can track each persons ID. Currently, save_crop just gives me the cropped images of the objectes detected, but there is not way to know from which frame of the video are the crops, also, which ID is attached which cropped image. The visualization through cv2.imshow shows the IDs accross the different frames, but I cant find a way to save them. The naming convention I am looking for is something like this: "frame_30_ID_1.jpg" My current code looks something like this: from ultralytics import YOLO model = YOLO("yolov8n.pt") # load model video_path = "path/to/video.mp4" ret = True while ret:
cap.release() Any help would be greatly apprecitated! Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi @pderrenger . Can I run the models using my phones camera? Can you please share the code to invoke my mobile's camera to test the model? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
Hi, help me understand why I get this error when tracking with segmentation model . My ultimate goal is to use a custom car plate segmentation model for tracking. Thank you very much
|
Beta Was this translation helpful? Give feedback.
-
Yolov8 has very high overall practicality. Can I implement tracking with two cameras? I hope that when a car tracked by camera A moves to camera B, its frame ID remains the same. However, currently there is always an ID switch happening. Is it because of the model's accuracy? def cam2(): cap=cam a = threading.Thread(target=cam1) a.start() |
Beta Was this translation helpful? Give feedback.
-
Hey there,
|
Beta Was this translation helpful? Give feedback.
-
Hi I saw that I can use an openvino IR format model just like any other pytorch model and then run tracking like normal. I was wondering how I would load the IR '.xml' and '.bin' files as arguments into YOLO(), or if I should load my model using openvino library? Thanks. |
Beta Was this translation helpful? Give feedback.
-
Can i use yolov8 model to track and reidentify person with same id assigned to it in multiple camera feed ? |
Beta Was this translation helpful? Give feedback.
-
How can we only track moving objects in the Plotting Tracks Over Time code: from collections import defaultdict import cv2 from ultralytics import YOLO Load the YOLOv8 modelmodel = YOLO('yolov8n.pt') Open the video filevideo_path = "path/to/video.mp4" Store the track historytrack_history = defaultdict(lambda: []) Loop through the video frameswhile cap.isOpened():
Release the video capture object and close the display windowcap.release() |
Beta Was this translation helpful? Give feedback.
-
import cv2 model = YOLO('yolov8_custom_train.engine', task="detect") Path to the input video fileinput_video_path = '/content/gdrive/MyDrive/yolov8-tensorrt/inference/output_video.mp4' Path to the output video fileoutput_video_path = 'outputtest_video.mp4' Define the coordinates of the polygonpolygon_points = [(670, 66), (1237, 550), (514, 1054), (161, 295)] Open the input video filecap = cv2.VideoCapture(input_video_path) Get video propertiesframe_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) Define the codec and create VideoWriter objectfourcc = cv2.VideoWriter_fourcc(*'mp4v') Function for finding the centroiddef calculate_centroid(box): Function to check if two bounding boxes overlapdef check_overlap(box1, box2): Read until video is completedwhile cap.isOpened():
Release video objectscap.release() Close all OpenCV windowscv2.destroyAllWindows() In this, I am tracking a label Person but in the next 2 to 3 frames, ids are changing so any solution for this? |
Beta Was this translation helpful? Give feedback.
-
What is the difference between these attributes of results[0].boxes: |
Beta Was this translation helpful? Give feedback.
-
is it possible to use our own weighs as a model to track? or we must include the yolov8n.pt? |
Beta Was this translation helpful? Give feedback.
-
So I am using Yolov8 for my current project, it's been a breeze so far. I do have a question on the tracking method provided by the Yolov8. When I am using the generic yolov8n model(or even a custom model mixed with few objects), I know I can specifically filter out things that doesn't interest me by their ID as below:
But, when I caught the an object that I am interested, can I at that time or at that frame, issue a track command to start tracking it? if it can be done, can you tell me how? an short example will be even better! thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
Hi, I want some detailed help and guidance on how to use custom tracker models with my custom yolov8 pose model, the Re-identification problem is being face using bytetrack.yaml so I think I should use StrongSORT or DeepSORT. Therefore, I want the ultralytics team to help me on selecting my tracker model or use multiple tracker models, and guide me properly on how to use them with my YOLOv8 custom trained model. |
Beta Was this translation helpful? Give feedback.
-
import random opening the file in read modemy_file = open("utils/coco.txt", "r") reading the filedata = my_file.read() replacing end splitting the text | when newline ('\n') is seen.class_list = data.split("\n") Generate random colors for class listdetection_colors = [] load a pretrained YOLOv8n modelmodel = YOLO("weights/yolov8n.pt", "v8") Vals to resize video frames | small frame optimise the runframe_wid = 640 def CarBehaviour(frame, color_threshold=1100):
def detect_and_draw(frame, model, class_list, detection_colors):
Open video capturecap = cv2.VideoCapture("/home/opencv_env/Vehicle-rear-lights-analyser-master/testing_data/road_2.mp4") if not cap.isOpened(): while True:
When everything done, release the capturecap.release() |
Beta Was this translation helpful? Give feedback.
-
Hello, thank you very much for your work on computer vision. I had a problem in development. For the same test video, the same model is used. When I use predict mode and track mode, there is a large performance gap in target recognition. This is reflected in that fewer target boxes are detected in track mode than in predict mode. I used the default byteTrack tracker or BoT Tracker. I have adjusted the tracker's hyperparameters for many times, but the problem has not been solved. May I ask why? |
Beta Was this translation helpful? Give feedback.
-
I'm trying to use the above example to track hockey players. I have tried many different configurations without great success. (ByteTrack and Botsort) As well as trying to use norrfair. If you watch the video you can see ID:4 changes many times after occlusion with another player. I have uploaded my examples to https://github.com/clearpaint/yolo/ |
Beta Was this translation helpful? Give feedback.
-
Hi we found that object id fluctuating within 19000 - 24000 is there any solution or controllable variable? |
Beta Was this translation helpful? Give feedback.
-
I have a problem with the tracker. I trained Segmentation Model 11, and tried the tracker with the model, but the tracker gives different IDs for the same object. How can I fix that? Are there any tips to solve the problem? Note: I read all the documents on the site but did not find a solution to my problem thank you for your help ! |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm using yolo11, with weights I trained myself. For some reason, the predict and track results are completely the same: model = YOLO(weights) After printing / plotting the annotations, it seems it exactly the same. Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
I have a model trained on about 1200 images (including augmented images) my project is to detect if there are 0,1 or 2 monkeys within each frame of the video. However if for example there is only one monkey seen in the frame the label will switch randomly between the two label names I have (for now we will say “monkey1” and “monkey2”). This is a problem for me because I save all the cropped images of each label and play it as a video for a closeup view. So then my cropped images will not be consistent. I have done the model.track(persist=True, agnostic_nms=True, iou=0.50) in order to try and reduce the likelihood of this happening however it still does more often then I would like. What options do I have in order to fix this or reduce the likelihood? I am also using Yolov11 fyi. Thank you so much for anything you come up with I’ve been stuck for weeks |
Beta Was this translation helpful? Give feedback.
-
i want to know the yolo model can process every resolution images as it is. or the process only for decided resolution (640,640). do you convert image size before the inference internally? |
Beta Was this translation helpful? Give feedback.
-
Can we use tracker mode other than bot sort and bytetrack? for example with deepsort tracker. |
Beta Was this translation helpful? Give feedback.
-
Hello, First, thank you for providing such excellent documentation! It has been incredibly helpful. I’m currently working on using the tracking model with my custom dataset, saving the tracking results, and eventually evaluating the performance using the TrackEval tool. Below is a snippet of my script that runs inference on video frames and writes the results to an output text file: cap = cv2.VideoCapture(video_path)
with open(output_file, 'w') as f:
frame_id = 0
while cap.isOpened():
success, frame = cap.read()
if not success:
break
results = model.track(frame, persist=True, tracker=tracker, conf=0.2, iou=0.25, classes=[0], verbose=False)
if results[0].boxes is not None:
for box in results[0].boxes:
bbox = box.xyxy[0].tolist()
track_id = int(box.id.item()) # if box.id is not None else -1
conf = box.conf.item() if box.conf is not None else -1
f.write(f'{frame_id+1},{track_id},{bbox[0]:.2f},{bbox[1]:.2f},{bbox[2]-bbox[0]:.2f},{bbox[3]-bbox[1]:.2f},{conf:.2f},-1,-1,-1\n') However, I encountered an issue with the line: track_id = int(box.id.item()) This results in the error: "AttributeError: 'NoneType' object has no attribute 'item'". To work around this, I assigned arbitrary IDs to entities without a box.id. Unfortunately, this led to another issue: Could you kindly advise on how to resolve this issue? I would greatly appreciate your guidance. Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
I have a question. When using the tracking module for target tracking and counting, is the processing time for each image printed just the YOLO time or does it include the post-tracking processing time? |
Beta Was this translation helpful? Give feedback.
-
Hi , I have fine tuned a segmentation model on my dataset, can I use it as my model in tracking or it must be a detection model? |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, I'm working with YOLOv8 and would like to use a tracker that's not natively implemented in the ultralytics library, such as Samurai or BoostTrack++. Could someone provide an example of how to integrate one of these external trackers with YOLOv8? Any guidance or example code would be greatly appreciated. Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, |
Beta Was this translation helpful? Give feedback.
-
Hi, can you please tell me if the tracker works better on more modern version of ultralytics or version 8.3.68 is no different from 8.1.34 ? (When using botsort.yaml) |
Beta Was this translation helpful? Give feedback.
-
Is it good to have more points in my label file? my dataset size is 30k images having total of 16 classes |
Beta Was this translation helpful? Give feedback.
-
modes/track/
Learn how to use Ultralytics YOLO for object tracking in video streams. Guides to use different trackers and customise tracker configurations.
https://docs.ultralytics.com/modes/track/
Beta Was this translation helpful? Give feedback.
All reactions