cv.jit.touches: ensuring constant order in labels (despite blob loss)

flim's icon

hello!

I've been playing around with cv.jit.touches for a bit and have one concern:

how can I keep up an even order in labels? usually I have to deal with blobs going lost - so after a while I won't have 10 blobs from 0 - 9, but 10 blobs accommodating labels as 1, 4, 6, 8, 9, 12, 14, 15, 19, 24 (due to dropouts). blobs moving up just take the next value (available in order)

I'd like to change that - have the next detected blob merely taking the last blob's place/label. it's important for installation issues that I keep a constant order in labels, to constantly avoid dropouts in values.

I've tried wrapping my head around it all day (it works to some extent). and won't see the wood for the trees for now..

the main issue: considering/combining continuative blob labeling with & without previous blob loss.

thankful for any advice..!

all the best

-jonas

Max Patch
Copy patch and select New From Clipboard in Max.

flim's icon

hello!

the above approach doesn't lead anywhere, so I've tried solving the issue with grand 'ol COLL

and still - flaws remain, as you can see in the following vid (1MB):

http://jonaswolf.com/cv.jit.touches.mov (download for bigger view)

it starts off they way I want it to actually proceed:
the first time my 2 blobs are lost/released (leave the screen), they get their old label back on return (I know that the actual issue here is that they don't literally RETURN).
on further loss-return activity they continue the old game - blob labelled "1" gets lost, next detected blob is labelled "2".

for anyone who's interested, here's what my max window tells me (outtake):

t for touch (new blob detected)
d for drag (current blob movement)
r for release (blob's lost)
(obviously)

don't look at it too long, it gets crazier & crazier :)

I'm certain I'm quite close in having cleansed my mistake, although I'm going quite nuts by now.

any suggestions appreciated (even if it's quite a diverging approach)..!

cheers

-jonas

Max Patch
Copy patch and select New From Clipboard in Max.

sorry for the mess. lock to make it look cleaner.

Jean-Marc Pelletier's icon

Hi,

I made an abstraction that renumbers the IDs output by cv.jit.touches. Try it out and let me know if it does what you want:

Jean-Marc

flim's icon

had it running in 1min [with live video feed] :)

it's exactly what I was looking for. thanks alot, jean-marc.. your cv.jit package is great work

all the best!

-jonas

ygreq's icon

I tested the patch myself and it seems it has to be a specific size otherwise it detects multiple blobs where there is only one. Is that true or am I doing something wrong?

ygreq's icon

Silly me! I now read what cv.jit.touches does. Track similarly-sized blobs. hehehhe. But it sure is sensitive to size. A little bigger and you screw everything!

Jean-Marc Pelletier's icon

Yeah, setting the parameters right is important, but it helps a lot if you have a good setup, hardware and lighting-wise. It works a lot better if you can get really clean-looking blobs in the first place.