Keeping track of tracked contours

hi there,

i stumbled into a problem i wasn’t able to solve for myself and hope for your help. here’s what i’d love to do:

i’m using a webcaminput with a trautner and a contour tracker to track changed regions in the image. contour is limited to 4 regions which i’d like to use as the triggers for 4 midi message senders. whenever a region with ID x appears, exactly one of the certain senders should send a note-on message and a note-off message as soon as region x dissapears.

the problem i’m facing is that index positions of ID x in contour’s output spread (listing the IDs) is kind of random. how is it possible to keep track of the IDs whether they are still here, trigger the midi-outs even when the indices of the IDs in the spread change all the time (i.e. check if a value is present in a spread and get its index). sorting the spread is merely a crutch for this problem and not really a solution…

that the regions IDs may increase much higher than the max-region-count makes this even harder.

i hope you got my dilemma.
thanks in advance!