z-x-yang / Segment-and-Track-Anything

An open-source project dedicated to tracking and segmenting any objects in videos, either automatically or interactively. The primary algorithms utilized include the Segment Anything Model (SAM) for key-frame segmentation and Associating Objects with Transformers (AOT) for efficient tracking and propagation purposes.
GNU Affero General Public License v3.0
2.75k stars 332 forks source link

increment before assignment #117

Open yrrah opened 9 months ago

yrrah commented 9 months ago

Please let me know if this is correct:

The background / unlabeled part of a mask is index 0.

If you have two objects being tracked, they would be index 1 & 2 and SegTracker.curr_idx = 2

Then when SegTracker.find_new_objs() finds one additional object, it should set the index in the resulting combined mask to SegTracker.curr_idx + 1 = 3

Currently the increment happens after assignment, so the third object incorrectly gets assigned SegTracker.curr_idx = 2

This might be the cause of https://github.com/z-x-yang/Segment-and-Track-Anything/issues/105