Open panyuxin1993 opened 1 month ago
Since the YOLOv10 model's code base is built with Ultralytics, you can save a text file similar to YOLOv8 track using the following code:
results = model(frame, verbose=False, save_txt=True)[0]
However, in the output file, you can't differentiate detections with frames. To include more details in the output file, you can use the following function instead of the method above:
def save_tracking_results(tracks, frame_count):
with open("./output/tracking_results.txt", "a") as file:
for track in tracks:
if not track.is_confirmed():
continue
track_id = track.track_id
ltrb = track.to_ltrb()
class_id = track.get_det_class()
file.write(f"Frame: {frame_count}, Track ID: {track_id}, Class ID: {class_id}, BBox: {ltrb}\n")
# Add after analyzing tracks inside the main function
save_tracking_results(tracks, frame_count) # Save results to the same text file
In YOLOv8, a function track can both show results on videos and save results as txt files for each frames. Can this tool achieve similar function? Or in future plan to add this valuable function?