Skip to content

Object ID for Tracking #6

@MarcMatute

Description

@MarcMatute

Hey there!

Firstly, thank you very much for your work! Probably it will be very useful.

For various reasons, I need to get the object ID for every object. I edited the code in such a way so that now I can see the object ID in the frame result. However, the way I did it seems like object IDs are not coherent frame after frame.

For example, here we have one object ID for a smoke object:

image

And the same object but with a different ID in the same video:

image

The changes I made are very little in the writing results part in detect.py:

`

             # Write results
            for idx, (*xyxy, conf, cls) in enumerate(reversed(det)):
            
                # Add the object_id to the label
                object_id = list(centroids.keys())[idx]
                c = int(cls)  # integer class
                label = None if hide_labels else (f'ID: {object_id} {names[c]}' if hide_conf else f'ID: {object_id} {names[c]} {conf:.2f}')
                
                annotator.box_label(xyxy, label, color=colors(c, True))
                
                if save_crop:
                    save_one_box(xyxy, imc, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)

`

Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions