Zero shot object tracking - get bounding boxes in csv file

I am implementing this nice code(GitHub - roboflow-ai/zero-shot-object-tracking: Object tracking implemented with the Roboflow Inference API, DeepSort, and OpenAI CLIP.) to tracking, but I want to have bounding boxes (xmin,xmax,ymin,ymax) in csv file. could you please help me??

The repo has a --save-txt flag that you can use to save tracking information to a file as you run the program if all you want to do is look back on how the script ran. Alternatively, it looks like you have specific data to save and a use case for a csv file which you can make with the function below. Just add the function to and call it when you want to save a bounding box.

# takes parameter bounding box ex: (xmin, xmax, ymin, ymax)
def save_bbox_to_csv(bbox):
    # Open our existing CSV file in append mode
    # Create a file object for this file
    with open('event.csv', 'a') as f_object:
        # Pass this file object to csv.writer()
        # and get a writer object
        writer_object = writer(f_object)
        # Pass the list as an argument into
        # the writerow()
        #Close the file object

Thanks for your help, I’ll try it.

1 Like