Colour tracking with a webcam in Jitter

njitram's icon

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

MIB's icon

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!!

Nate's icon

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

njitram's icon

@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 jit.qt.movie with a jit.dx.grab but this will probably too simplistic?
My jit.findbounds values stay on -1.

Thx for the replies!

2328.colortracking.maxpat
Max Patch
njitram's icon

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

MIB's icon
Max Patch
Copy patch and select New From Clipboard in Max.

try the below. Works great for me...

njitram's icon

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

MIB's icon

[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

HTH

Joe's icon

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,

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

MIB's icon

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 ;)

Joe's icon

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

J

Joe's icon

Hey

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?

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

J

Joe's icon

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

what does that mean?

j

yaniki's icon

Hi Joe

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

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

- '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"!)

Joe's icon

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.

yaniki's icon

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

yaniki's icon
Max Patch
Copy patch and select New From Clipboard in Max.

And test attached patch:

Joe's icon

that patch works perfectly!

what colour is it tracking though?

yaniki's icon

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.

yaniki's icon

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

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

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

Joe's icon

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?

yaniki's icon

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

yaniki's icon

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.

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

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

Joe's icon

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

yaniki's icon

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.

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

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).

Joe's icon

Hi

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

J

yaniki's icon

Joe!

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

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

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

adriananyu's icon

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

Chloe  Black's icon

Hi! this patch saved the day for me, is there any way of imputing an audio file into this and when you move the coloured object through the tracker it changed the pitch of the audio???