Search code examples
pythonyolo

Save YOLOv4 with deepSORT prediction info such as coords and ID


I'm following this tutorial (https://github.com/theAIGuysCode/yolov4-deepsort). I now want to save the predictions into one file (csv/txt/anything) in terms of class, ID, and coordinate location. I've looked online but can't seem to find a solution. I especially need the ID value.

I can use the argument --info to show this information in the Anaconda prompt but I just need the info in a saved file.

Any help would be much appreciated!


Solution

  • You can modify object_tracker.py, line 219, and save the info to a file:

    with open('output.txt', 'a') as f:
        f.write("Tracker ID: {}, Class: {},  BBox Coords (xmin, ymin, xmax, ymax): {}".format(str(track.track_id), class_name, (int(bbox[0]), int(bbox[1]), int(bbox[2]), int(bbox[3])))))
    f.close