Colour tracking with a webcam in Jitter

Jun 4, 2011 at 4:40pm

Colour tracking with a webcam in Jitter

Is it possible to do this with jitter?
I tried to replace the in tutorial25 with jit.dx.grab but that doesnt seem to work?

Jun 4, 2011 at 6:13pm

yes of course it’s possible. that’s why there is a tutorial for it ;)
we need a bit more info. what did you try? what didn’t work? what were you expecting and what did you get? did you give jit.findbounds good values to track? did you look into [suckah] to get color values for jit.findbounds?

post a patch!!

Jun 4, 2011 at 8:47pm

You may also want to check out cv.jit.*

Jun 5, 2011 at 9:30am

@MIB I i’m following the tutorial nr 25 from the Jitter Tutorials, but thats not with a webcam but with a normal video.
I just replaced the with a jit.dx.grab but this will probably too simplistic?
My jit.findbounds values stay on -1.

Thx for the replies!

Jun 5, 2011 at 2:51pm

I’m trying to do the same as he is doing, but my valeus stay at -1

Jun 5, 2011 at 6:07pm

try the below. Works great for me…

– Pasted Max Patch, click to expand. –
Jun 6, 2011 at 2:12pm

cool, works great.
how do you change the padding of the color ?
can’t understand the little formula you made there :D

Jun 6, 2011 at 5:34pm

[vexpr $f1 - ($f1 * 0.01) @scalarmode 1]

$f1… take the list from the first inlet
$f1 * 0.01 …. get 10% of each element of that list
add or subtract the padding to the original list
@scalarmode 1… operate on each element of the list


Jun 30, 2013 at 8:30am

I had a bit of trouble with the patch you posted unfortunately.

I have converted tutorial 25 to work with webcam video but the tracking of colour isn’t working. Could someone have a look at what is wrong with it? And is there a way of setting what colour to look for?

All the best,

– Pasted Max Patch, click to expand. –
Jul 1, 2013 at 2:38pm

works fine for me when I change it to look for red (I am wearing a red t-shirt right now)… what’s the issue?? more info is always good ;)

Jul 1, 2013 at 3:00pm

hmm thats odd. I open webcam and turn it on and I see me moving about.. but not change in numbers :/

how have you changed it to look for red?

all the best


Jul 3, 2013 at 5:17am


still having a bit of trouble with this patch, I think I have set it to search only for red, but I still get no movement from the sliders or floats.

Any suggestions?



– Pasted Max Patch, click to expand. –


Jul 3, 2013 at 5:44am

I have noticed the max window is outputting, “could not build preview graph”

what does that mean?


Jul 3, 2013 at 6:57am

Hi Joe

Your patch is working fine on my computer (OSX, Max 6.1.3) – I changed it only a bit:

- ’cause I’m not using CV I’m using jit.grab
- changed “unpack” to “unpack i i”
- added manual control for min and max (be sure you always using “1.” for alpha value – not “0.1″!)


– Pasted Max Patch, click to expand. –


Jul 3, 2013 at 7:18am

Hmm this is really odd. I am testing your patch and still getting no tracking. Even when I put a red pen lid right up to the webcam I get no movement of the sliders.

Jul 3, 2013 at 7:23am

Joe, please make for me a screenshot of your patch with parameters (min and max, etc.). I’m sure we can find a solution ;-)

Jul 3, 2013 at 7:28am

And test attached patch:


– Pasted Max Patch, click to expand. –


Jul 3, 2013 at 7:31am

that patch works perfectly!

what colour is it tracking though?

Jul 3, 2013 at 7:34am

Just white and light-grey. Your problem is (or was) related to min and max parameters – I have an idea, how to do it, wait a bit for next patch.

Jul 3, 2013 at 8:00am

A lot of optimisations possible, but this is good enough for beginning…

Just click on “pwindow” to select color to track and use “tolerance” slider to tune sensitivity of the tracker. And have hun ;-)


– Pasted Max Patch, click to expand. –


Jul 3, 2013 at 12:06pm

Interesting approach, really like the ability to click on the colour to track.

I am getting some very sporadic results mind, not sure if I have set it up right but I (change in numbers) until the tolerance is increased to about 0.6 and even then I don’t think it is tracking what I want it to.

Any suggestions?

Jul 3, 2013 at 12:42pm

Interesting… I think I can return to the patch tomorrow ;-)

Jul 3, 2013 at 2:15pm

Hmmm… I played with the patch a bit. Maybe i’s something wrong with the jit.findbounds (I can reproduce your problem on my computer) or there’s a bug in the patch – I’m not sure. But we can workaround this problem anyway.

Check attached patch – I moved some parts of the work into jit.pix and jit.fastblur objects. Hope, this is helpful.


– Pasted Max Patch, click to expand. –


Jul 3, 2013 at 3:10pm

Its strange because I have built a patch pretty similar to this that tracks my white iphone really well. The patch you posted doesnt seem to track the colour selected.

Interestingly the data that is produced in the number boxs out of the two unpack i i seems to stay around 200, 60, 277 and 137 even when I change the colour I am looking for..

Not sure if that helps with your diagnostic of the patch

Jul 3, 2013 at 3:54pm

On my computer I can track selected colour, I’m sure. Please make screenshots of the patch during tracking with source and processed image. I can’t reproduce this issue.

Maybe this is something PC specific or your camera (and lighting condition) is producing noisy image. Try also play with “range” attribute of jit.fastblur (it’s simply with attached patch).


– Pasted Max Patch, click to expand. –


Jul 4, 2013 at 5:45am


Yeah those changes have cleared it right up. thank you so much for your effort.

I can now change it to fit my patch and get some decent tracking results.

All the best


Jul 4, 2013 at 6:29am


Great! That was surprisingly spooky topic… I’m glad we solved all the problems.

I attached once again a bit cleared version of the patch – maybe it will be inspiring for somebody in the future.


– Pasted Max Patch, click to expand. –


Nov 24, 2013 at 3:09pm

Yaniki – this patch just saved me an entire day! Thank you!


You must be logged in to reply to this topic.