Forums > Jitter

cv.jit.centroid question

July 10, 2008 | 8:47 pm

hi!using cv.jit.centroid is it possible to have only one centroid instead of
many?

for example, 4 blobs are detected and what i need is the center of this 4
blobs.. can someone give me a help on this?

regards
morin


July 11, 2008 | 12:54 am

calculate a average of the centroids.
suppose you have 4 blobs.
add them all and divide by 4..
50 100
66 98
45 12
79 38
———- +
240 248
———— /4
60 62

On Thu, Jul 10, 2008 at 11:47 PM, grooover morin
wrote:

> hi!using cv.jit.centroid is it possible to have only one centroid instead
> of many?
>
> for example, 4 blobs are detected and what i need is the center of this 4
> blobs.. can someone give me a help on this?
>
> regards
> morin
>
>
>


July 11, 2008 | 1:10 am

Yeah, there’s a parameter you can pass it. Check the example patch.
(Sorry, I don’t have a working copy of Max atm).

On Thu, Jul 10, 2008 at 8:54 PM, yair reshef wrote:
> calculate a average of the centroids.
> suppose you have 4 blobs.
> add them all and divide by 4..
> 50 100
> 66 98
> 45 12
> 79 38
> ———- +
> 240 248
> ———— /4
> 60 62
>
>
> On Thu, Jul 10, 2008 at 11:47 PM, grooover morin
> wrote:
>>
>> hi!
>> using cv.jit.centroid is it possible to have only one centroid instead of
>> many?
>> for example, 4 blobs are detected and what i need is the center of this 4
>> blobs.. can someone give me a help on this?
>> regards
>> morin
>>
>
>
>
>


Morgan Sutherland


July 11, 2008 | 9:37 am


July 12, 2008 | 12:32 am

Or, more easily, simply send the output of cv.jit.blobs.centroids to jit.3m. The middle outlet will give you the average position of the centroids like below.

Quote: yair r. wrote on Fri, 11 July 2008 09:54
—————————————————-
> calculate a average of the centroids.
> suppose you have 4 blobs.
> add them all and divide by 4..
> 50 100
> 66 98
> 45 12
> 79 38
> ———- +
> 240 248
> ———— /4
> 60 62
>
>


July 13, 2008 | 12:06 am

Thanks Jean!! This seems to be what i need!


July 13, 2008 | 9:25 am

Sorry groover! I thought this was in the example patch, but it isn’t.

Here’s how to do it with cv.jit.blobs.centroids:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 33 197 66 196617 jit.rgb2luma;
#P toggle 257 197 15 0;
#P newex 257 217 29 196617 gate;
#P newex 33 256 103 196617 jit.op @op < @val 50;
#P number 120 237 35 9 0 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname threshold;
#P user jit.pwindow 256 236 322 242 0 0 0 0 1 0;
#P newex 144 262 66 196617 loadmess 20;
#P number 144 281 27 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname blobThresh;
#P message 144 298 65 196617 threshold $1;
#P newex 125 349 60 196617 loadmess 2;
#P number 125 368 35 9 1 200 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname numOfBlobs;
#P newex 33 385 108 196617 jit.op @op < =p @val 3;
#P newex 33 320 190 196617 cv.jit.label @charmode 1 @threshold 20;
#P newex 33 438 132 196617 cv.jit.blobs.centroids.draw;
#P newex 33 411 106 196617 cv.jit.blobs.centroids;
#P comment 161 369 64 196617 Num of blobs;
#P comment 162 439 82 196617 draw crosshairs;
#P comment 140 414 97 196617 centroid coordinates;
#P message 136 137 44 196617 settings;
#P message 117 108 31 196617 close;
#P message 86 108 28 196617 open;
#P toggle 33 84 15 0;
#P newex 33 108 46 196617 metro 2;
#P newex 33 136 98 196617 jit.qt.grab 160 120;
#P connect 20 0 11 0;
#P connect 20 0 10 1;
#P connect 10 0 21 1;
#P fasten 15 0 11 0 149 316 38 316;
#P connect 11 0 12 0;
#P connect 23 0 20 0;
#P connect 19 0 20 1;
#P connect 0 0 23 0;
#P connect 12 0 9 0;
#P connect 9 0 10 0;
#P connect 14 0 13 0;
#P connect 13 0 12 1;
#P connect 17 0 16 0;
#P connect 16 0 15 0;
#P connect 22 0 21 0;
#P connect 21 0 18 0;
#P connect 2 0 1 0;
#P hidden connect 5 0 0 0;
#P fasten 3 0 0 0 91 130 38 130;
#P fasten 4 0 0 0 122 130 38 130;
#P connect 1 0 0 0;
#P window clipboard copycount 24;

On Sat, Jul 12, 2008 at 8:06 PM, grooover morin wrote:
> Thanks Jean!!
> This seems to be what i need!
>
>
>
>


Morgan Sutherland


July 13, 2008 | 10:52 am


Viewing 8 posts - 1 through 8 (of 8 total)