cv.jit.label - cv.jit.blobs.centroids for multiple objects

jamie jewett's icon

Greetings folks

I am trying to work with cv.jit.label into cv.jit.blobs.centroids to track 3 objects -

I get the 3 objects fine in my cv.jit.centroids.draw output but I am trying to get the xy points for each blob separately....

tracking for one as follows - how to do this with 3....

many thanks

jamie

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

nesa's icon

>
> tracking for one as follows - how to do this with 3....

tracking is the same for multiple blobs too.

from cv.jit.blobs.centroids helpfile:

cv.jit.blobs outputs a single-row, 3-plane char matrix where the
number of cells is the same as the number of labeled components. The
contents of each plane is as follows:
Plane 1: x-coordinate
Plane 2: y-coordinate
Plane 3: area

If you open cv.jit.blobs.centroids.draw patch, you'll see that
jit.iter iterates through all the cells in the matrix(all blobs)
giving you a list of maxland values(x , y, area).

hope this helps,
nesa

>
> many thanks
>
> jamie
>
> max v2;
> #N vpatcher 20 74 620 474;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 102 91 46 196617 jit.print;
> #P newex 77 224 107 196617 jit.op @op * @val -1.;
> #P newex 60 278 53 196617 jit.pack 3;
> #P newex 95 248 143 196617 jit.map @map 0 1000 0. 0.01;
> #P newex 77 200 130 196617 jit.map @map 0 239 -1. 1.;
> #P newex 60 172 130 196617 jit.map @map 0 319 -1. 1.;
> #P newex 60 145 63 196617 jit.unpack 3;
> #P newex 60 121 106 196617 cv.jit.blobs.centroids;
> #P newex 60 60 190 196617 cv.jit.label @charmode 1 @threshold 10;
> #P connect 0 0 1 0;
> #P connect 1 0 2 0;
> #P connect 2 0 3 0;
> #P connect 3 0 6 0;
> #P connect 2 1 4 0;
> #P connect 4 0 7 0;
> #P connect 7 0 6 1;
> #P connect 2 2 5 0;
> #P connect 5 0 6 2;
> #P pop;
>
>
>

jamie jewett's icon

thanks nesa

sorry to be thick headed about this but how to best then chop up the data fro cv.jit.centroids into several one cell matrix(s) (matrixi) (( :? ))

I tried to use
jit.submatrix @dim 1 1 @offset 0 0
and
jit.submatrix @dim 1 1 @offset 1 0

but get no values from this

well - just zero values - if I use dim 4 1 for example, with 3 tracked objects then I get 3 cells showing up in my jit cell block - but they are all a 0.0 value

you said that centroids iterates through but I am not seeing this if i print the data -
(or i am not properly understanding this somehow)
here are 2 example bangs

129.953 121.553 190.000, 161.600 158.482 85.000, 165.500 163.000 2.000

126.138 150.408 152.000, 160.090 182.321 78.000, 165.000 185.875 8.000

hmmm -
can someone give me a direction to fumble in please

thanks

jamie

----- Original Message ----
From: nesa
Sent: Sunday, October 7, 2007 1:04:09 PM
Subject: Re: [jitter] cv.jit.label - cv.jit.blobs.centroids for multiple objects

>
> tracking for one as follows - how to do this with 3....

tracking is the same for multiple blobs too.

from cv.jit.blobs.centroids helpfile:

cv.jit.blobs outputs a single-row, 3-plane char matrix where the
number of cells is the same as the number of labeled components. The
contents of each plane is as follows:
Plane 1: x-coordinate
Plane 2: y-coordinate
Plane 3: area

If you open cv.jit.blobs.centroids.draw patch, you'll see that
jit.iter iterates through all the cells in the matrix(all blobs)
giving you a list of maxland values(x , y, area).

hope this helps,
nesa

>
> many thanks
>
> jamie
>
> max v2;
> #N vpatcher 20 74 620 474;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 102 91 46 196617 jit.print;
> #P newex 77 224 107 196617 jit.op @op * @val -1.;
> #P newex 60 278 53 196617 jit.pack 3;
> #P newex 95 248 143 196617 jit.map @map 0 1000 0. 0.01;
> #P newex 77 200 130 196617 jit.map @map 0 239 -1. 1.;
> #P newex 60 172 130 196617 jit.map @map 0 319 -1. 1.;
> #P newex 60 145 63 196617 jit.unpack 3;
> #P newex 60 121 106 196617 cv.jit.blobs.centroids;
> #P newex 60 60 190 196617 cv.jit.label @charmode 1 @threshold 10;
> #P connect 0 0 1 0;
> #P connect 1 0 2 0;
> #P connect 2 0 3 0;
> #P connect 3 0 6 0;
> #P connect 2 1 4 0;
> #P connect 4 0 7 0;
> #P connect 7 0 6 1;
> #P connect 2 2 5 0;
> #P connect 5 0 6 2;
> #P pop;
>
>
>

yair reshef's icon

hi, u chope a matrix into signal cells using jit.iter.

On 10/8/07, jamie jewett wrote:
>
> thanks nesa
>
> sorry to be thick headed about this but how to best then chop up the data
> fro cv.jit.centroids into several one cell matrix(s) (matrixi) (( :? ))
>
> I tried to use
> jit.submatrix @dim 1 1 @offset 0 0
> and
> jit.submatrix @dim 1 1 @offset 1 0
>
> but get no values from this
>
> well - just zero values - if I use dim 4 1 for example, with 3 tracked
> objects then I get 3 cells showing up in my jit cell block - but they are
> all a 0.0 value
>
> you said that centroids iterates through but I am not seeing this if i
> print the data -
> (or i am not properly understanding this somehow)
> here are 2 example bangs
>
> 129.953 121.553 190.000, 161.600 158.482 85.000, 165.500 163.000 2.000
>
> 126.138 150.408 152.000, 160.090 182.321 78.000, 165.000 185.875 8.000
>
> hmmm -
> can someone give me a direction to fumble in please
>
> thanks
>
> jamie
>
>
> ----- Original Message ----
> From: nesa
> Sent: Sunday, October 7, 2007 1:04:09 PM
> Subject: Re: [jitter] cv.jit.label - cv.jit.blobs.centroids for multiple
> objects
>
> >
> > tracking for one as follows - how to do this with 3....
>
> tracking is the same for multiple blobs too.
>
> from cv.jit.blobs.centroids helpfile:
>
> cv.jit.blobs outputs a single-row, 3-plane char matrix where the
> number of cells is the same as the number of labeled components. The
> contents of each plane is as follows:
> Plane 1: x-coordinate
> Plane 2: y-coordinate
> Plane 3: area
>
> If you open cv.jit.blobs.centroids.draw patch, you'll see that
> jit.iter iterates through all the cells in the matrix(all blobs)
> giving you a list of maxland values(x , y, area).
>
> hope this helps,
> nesa
>
>
> >
> > many thanks
> >
> > jamie
> >
> > max v2;
> > #N vpatcher 20 74 620 474;
> > #P window setfont "Sans Serif" 9.;
> > #P window linecount 1;
> > #P newex 102 91 46 196617 jit.print;
> > #P newex 77 224 107 196617 jit.op @op * @val -1.;
> > #P newex 60 278 53 196617 jit.pack 3;
> > #P newex 95 248 143 196617 jit.map @map 0 1000 0. 0.01;
> > #P newex 77 200 130 196617 jit.map @map 0 239 -1. 1.;
> > #P newex 60 172 130 196617 jit.map @map 0 319 -1. 1.;
> > #P newex 60 145 63 196617 jit.unpack 3;
> > #P newex 60 121 106 196617 cv.jit.blobs.centroids;
> > #P newex 60 60 190 196617 cv.jit.label @charmode 1 @threshold 10;
> > #P connect 0 0 1 0;
> > #P connect 1 0 2 0;
> > #P connect 2 0 3 0;
> > #P connect 3 0 6 0;
> > #P connect 2 1 4 0;
> > #P connect 4 0 7 0;
> > #P connect 7 0 6 1;
> > #P connect 2 2 5 0;
> > #P connect 5 0 6 2;
> > #P pop;
> >
> >
> >
>
>
>
>
>
>
>

jazmatajz's icon

try this:

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

j

nesa's icon

why do you want to use several one cell matrices?

> sorry to be thick headed about this but how to best then chop up
> the data fro cv.jit.centroids into several one cell matrix(s)
> (matrixi) (( :? ))

If you really want to chop up the matrix, and jit.submatrix refuses
to cooperate, you can use @usesrcdim 1 @srcdimstart/end attributes of
jit.matrix or maybe jit.scissors.

> you said that centroids iterates through but I am not seeing this
> if i print the data -

I said that cv.jit.blobs.centroids.DRAW jit.iterates through incoming
jit.matrix

> 129.953 121.553 190.000, 161.600 158.482 85.000, 165.500 163.000
> 2.000

These are three simple max lists coming out of jit.iter, containing
iterated jit.matrix cell values, refering to:

blob(n).x blob(n).y blob(n).area

where n is blob index - wich comes out of second outlet of jit.iter.

here's an example patch:

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

jamie jewett's icon

---why do you want to use several one cell matrices?
trying to use the location data from several (objects) to draw with

ok

I tried scissors didn't work either

---@usesrcdim 1 @srcdimstart/end attributes of jit.matrix
I'll try this method and see if i can get it to work

----I said that cv.jit.blobs.centroids.DRAW jit.iterates through incoming jit.matrix----

your patch didn't work for me -
saw the 3 color blobs moving around but the zl slice thingy into the pictsliders gives no movement
and the cellblock always reports 159.500 for some reason...

but I'll try the iter gate combo and se if I can get that one to work... - have to put the #'s back into matrix...

thanks for your help on this

I REALLY appreciate it!

best
jamie

> 129.953 121.553 190.000, 161.600 158.482 85.000, 165.500 163.000
> 2.000

These are three simple max lists coming out of jit.iter, containing
iterated jit.matrix cell values, refering to:

blob(n).x blob(n).y blob(n).area

where n is blob index - wich comes out of second outlet of jit.iter.

here's an example patch:

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

nesa's icon

>
> ---why do you want to use several one cell matrices?
> trying to use the location data from several (objects) to draw with

ok, but how do you want to draw them? jit.lcd, opengl? for the later,
you might not need to de-matrix a matrix...

> ----I said that cv.jit.blobs.centroids.DRAW jit.iterates through
> incoming jit.matrix----
>
> your patch didn't work for me -
> saw the 3 color blobs moving around but the zl slice thingy into
> the pictsliders gives no movement

were the rgb circles drawn on the black background?
if they were on white backround, then there's probably a missing
loadbang in |p rgb flies| - open it and click 'brgb 0 0 0' message,
or save&reopen the patch.

but if the background was black, and the patch didn't work - then you
might have a bit more serious problem.

hth,
nesa

jamie jewett's icon

YEAH

missing load bang indeed

and yes - right wanted to leave it in matrix form so the
jit.matrix 2 float32 1 @adapt 0 @usesrcdim 1 @srcdimstart 2 @srcdimend 3

is just right

many thanks!!

j