drawing 'ribbons' based on video tracking

Jun 24, 2008 at 6:35pm

drawing 'ribbons' based on video tracking

I’m an old hat at MAX/MSP but very new to Jitter. I am working on a dance piece and would like to track a bright point on the dancer (I can do that part in a variety of ways) that creates a projected line or ‘ribbon’ as that point moves. Ideally, the ribbon would be erasing the oldest points to keep a maximum length, though I could also use an ‘erase’ if necessary. Another nice touch would be to vary the ribbon’s thickness by the mass or speed of the centroid I am tracking.

I’ve looked at a variety of approaches on this forum, but have either missed or not been able to connect all the dots from the various approaches to do what I want. I’ve looked at jit.slide examples, jit.gl.slab, jit.gl.sketch examples, downloaded the cv.jit objects, and looked at most of the posts for generating ‘trails,’ though I would like to be actually drawing, and not blurring movs.

If there are any good examples out there that can be shared, or that I have missed on this forum, please let me know. I’m a week into this and my deadline approaches quickly.

J.

#38572
Jun 24, 2008 at 9:23pm

just an idea
maybe jitter particles can do the job, something like: http://www.videocopilot.net/tutorial.html?id=29*

#134644
Jun 24, 2008 at 9:29pm

another idea
a-hspline3d from http://www.s373.net/code/a-objects

#134645
Jun 24, 2008 at 9:39pm

haa,
that was from game programming gems! nice gem.

a

On Jun 24, 2008, at 10:29 PM, jasmin wrote:

>
> another idea
> a-hspline3d from http://www.s373.net/code/a-objects
>
> –
> jaz

#134646
Jun 25, 2008 at 6:07pm

Thanks for both sites. The Videocopilot one was excellent for other reasons, though it might be beyond my novice status at the moment to translate the After Effects techniques into Jitter patches.

And I certainly will try out the a-hspline3d object–in fact, the whole set of objects looks very promising.

I’d still be interested if anyone had any working examples of drawing by tracking out there.

Thanks for the help so far,

Jeff

#134647
Jun 26, 2008 at 11:08pm

Hi,

pasted below is an example on how to draw curves using jit.gl.sketch,
added on top of the example jasch posted in another thread.

enjoy,
nesa

– Pasted Max Patch, click to expand. –
#134648
Jun 26, 2008 at 11:18pm

———-begin_max4_patcher– ?

On Fri, Jun 27, 2008 at 2:08 AM, nesa wrote:

> Hi,
>
> pasted below is an example on how to draw curves using jit.gl.sketch, added
> on top of the example jasch posted in another thread.
>
> enjoy,
> nesa
>
>

– Pasted Max Patch, click to expand. –

>
>
>

#134649
Jun 26, 2008 at 11:27pm

he he, give me ten minutes to repatch…

On Jun 27, 2008, at 1:18 AM, yair reshef wrote:

> ———-begin_max4_patcher– ?
>
>
> On Fri, Jun 27, 2008 at 2:08 AM, nesa wrote:
> Hi,
>
> pasted below is an example on how to draw curves using
> jit.gl.sketch, added on top of the example jasch posted in another
> thread.
>
> enjoy,
> nesa

#134650
Jun 26, 2008 at 11:39pm

#P button 501 442 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 10 59 238 266;
#P window setfont “Sans Serif” 9.;
#P newex 70 35 48 196617 loadbang;
#P message 24 81 130 196617 reset , beginstroke basic2d;
#P outlet 24 147 15 0;
#P inlet 24 26 15 0;
#P connect 3 0 2 0;
#P connect 0 0 2 0;
#P connect 2 0 1 0;
#P pop;
#P newobj 508 477 73 196617 p start stroke;
#N vpatcher 986 653 1586 1053;
#P button 174 215 15 0;
#P outlet 119 312 15 0;
#P window setfont “Sans Serif” 9.;
#P comment 330 292 129 196617 see jit.gl.sketch reference;
#P comment 330 277 215 196617 delete oldest point (width , color ,
position);
#P message 119 275 204 196617 cmd_delete 1 , cmd_delete 1 ,
cmd_delete 1;
#P newex 119 224 32 196617 sel 1;
#P newex 119 177 30 196617 > 60;
#N counter;
#X flags 0 0;
#P newobj 119 140 66 196617 counter;
#P newex 119 104 20 196617 t b;
#P inlet 215 56 15 0;
#P inlet 119 60 15 0;
#P comment 221 182 100 196617 keep up to 60 points;
#P connect 1 0 3 0;
#P connect 3 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 10 0;
#P connect 2 0 4 2;
#P connect 5 0 11 0;
#P pop 1;
#P newobj 433 478 68 196617 p trail length;
#N vpatcher 10 59 582 438;
#P window setfont “Sans Serif” 9.;
#P message 46 158 349 196617 strokeparam scale $3 , strokeparam
color $4 0. 0. 1. , strokepoint $1 $2 0.;
#P outlet 46 301 15 0;
#P inlet 46 29 15 0;
#P comment 169 235 100 196617 check jit.gl.sketch reference;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P pop;
#P newobj 360 478 66 196617 p add a point;
#N vpatcher 316 447 835 843;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 173 274 100 196617 x , y , width color;
#P outlet 83 320 15 0;
#P newex 83 273 78 196617 pack 0. 0. 0. 0.;
#P newex 227 224 105 196617 scale 0. 0.5 1. 0.3 4.;
#P newex 127 225 93 196617 scale 0. 0.5 0.2 0.;
#P window linecount 0;
#P newex 227 169 47 196617 cartopol;
#P inlet 83 35 15 0;
#N vpatcher 20 74 215 340;
#P outlet 69 210 15 0;
#P window setfont “Sans Serif” 9.;
#P newex 46 144 83 196617 vexpr $f2 – $f1;
#P newex 69 104 27 196617 t l l;
#P inlet 69 30 15 0;
#P connect 1 1 2 0;
#P connect 0 0 1 0;
#P connect 2 0 3 0;
#P connect 1 0 2 1;
#P pop;
#P newobj 227 131 40 196617 p delta;
#P comment 339 227 100 196617 handpicked values;
#P connect 2 0 6 0;
#P connect 6 0 7 0;
#P connect 3 0 4 0;
#P connect 4 0 6 2;
#P connect 5 0 6 3;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 5 0;
#P pop;
#P newobj 360 440 54 196617 p mapping;
#P message 212 70 69 196617 idlemouse $1;
#P newex 212 30 60 196617 loadmess 1;
#P user jit.pwindow 211 89 322 242 0 1 1 0 1 0;
#X name WORLD;
#P newex 212 493 22 196617 b 1;
#P newex 212 520 104 196617 pack position 0. 0. 0.;
#P newex 212 465 51 196617 zl slice 2;
#P newex 212 553 375 196617 jit.gl.gridshape WORLD @scale 0.1 0.1 0.1
@lighting_enable 1 @color 1. 0.5 0. 1.;
#P newex 212 337 112 196617 route mouse mouseidle;
#P newex 212 439 102 196617 route screentoworld;
#P message 212 362 105 196617 screentoworld $1 $2;
#P toggle 10 30 15 0;
#P newex 10 406 212 196617 jit.gl.render WORLD @erase_color 0. 0. 0. 1.;
#P newex 10 77 58 196617 t b b erase;
#P newex 10 52 57 196617 qmetro 20;
#P newex 433 514 98 196617 jit.gl.sketch WORLD;
#P comment 519 442 100 196617 reset;
#P connect 18 0 1 0;
#P connect 17 0 1 0;
#P connect 19 0 1 0;
#P connect 16 0 17 0;
#P connect 16 0 18 0;
#P connect 14 0 15 0;
#P connect 10 0 12 0;
#P connect 10 0 11 1;
#P fasten 10 0 16 0 305 504 353 419;
#P connect 20 0 18 1;
#P connect 20 0 19 0;
#P connect 7 0 10 0;
#P connect 12 0 11 0;
#P connect 8 1 6 0;
#P connect 8 0 6 0;
#P connect 13 1 8 0;
#P connect 5 0 2 0;
#P connect 2 0 3 0;
#P connect 6 0 4 0;
#P connect 3 2 4 0;
#P connect 3 0 4 0;
#P connect 4 1 7 0;
#P connect 15 0 13 0;
#P connect 11 0 9 0;
#P window clipboard copycount 21;

On Jun 27, 2008, at 1:27 AM, nesa wrote:

> he he, give me ten minutes to repatch…
>
> On Jun 27, 2008, at 1:18 AM, yair reshef wrote:
>
>> ———-begin_max4_patcher– ?
>>
>>
>> On Fri, Jun 27, 2008 at 2:08 AM, nesa wrote:
>> Hi,
>>
>> pasted below is an example on how to draw curves using
>> jit.gl.sketch, added on top of the example jasch posted in another
>> thread.
>>
>> enjoy,
>> nesa

#134651
Jun 29, 2008 at 2:38pm

Nesa,
Thank you so much–that is just what I was looking for. I am having great fun adding attributes and my knowledge of gl has multiplied many orders of magnitude. I notice that quick moves of the mouse will give a more contoured ribbon…while I think I have figured out most of what is happening, I have not been able to replicate that effect at a lower speed. If you consider that the 320 pixels will represent a 40′-wide stage, I’d have to have a VERY fast dancer to recreate that effect–any suggestions on how to do that at a lower speed?
Thanks SO much again,
Jeff

#134652
Jun 29, 2008 at 4:27pm

Hi,

well, then easiest solution is to hire Bruce Lee to move fast enough,
but since he’s not available for quite some time now, we’ll have to
figure out something differenct.

My guess is that when you move mouse faster – you have less points per
length. So, in ‘camera’ case you would have to apply some kind of data
reduction. This is pretty common problem for all sensors(and camera is
just another sensor), so perhaps it would be good idea to search the
forum and try to find the best solution for your application.

One way to do data reduction would be to add a new point only when
line angle(and distance) changes more then some threshold level.
If you look at the ‘p mapping’ sub-patch, you’ll see that there is ‘p
delta’ sub-patch which calculates the difference between coordinates
of the current and previous point. Output of delta is connected to the
cartopol object which calculates the angle and distance between these
two points.
This is the place where you could check for these values, and based on
that decide if you want to open the gate and trigger ‘pack 0. 0. 0.’
to add a point.

Hope this helps,
and thanks for nice question.

-nesa

#134653
Jun 29, 2008 at 5:59pm

Ha, I just figured it out before checking the forum again. Yes, it is the delta subpatch–I can change the scaling values and get the contouring results I need! And I also added a multiply factor for the delta value. In fact, changing them in realtime based on tracking data makes the patch even more dynamic.

I was thinking more of a catapult for the dancer. Thanks again–I think I got even more than I need to continue on with my piece now. My first encounter with the Jitter forum has provided 100% satisfaction…thank you all.

Jeff

#134654
Jun 2, 2009 at 3:27am

Hi,

I am attempting to modify the below patch posted by nesa using jit.gl.sketch to draw ribbon-like trails. The patch I am using is really complicated so it is easier for me to refer to nesa’s original post. The problem I am running into has to do with the color of the trail which is in the encapsulated patch “add a point”. If I remove the “strokeparam color” message from this encapsulated patch in order to create a separate message that I can send color values to, the trail settings break. I have to keep triggering the reset button to get the trail to appear but it disappears after a short time.

Can someone explain to me how I could change the color of the trail “live” with color settings either attached to the current “add a point” encapsulated patch or how to make a new message that won’t cause the odd behavior of the trail disappearing?
I’ve searched for more information about the strokeparam message but have not found anything helpful in the documentation.

Any help is greatly appreciated!!

Lisa Marie

nesa wrote on Thu, 26 June 2008 19:08

Hi,

pasted below is an example on how to draw curves using jit.gl.sketch,
added on top of the example jasch posted in another thread.

enjoy,
nesa

– Pasted Max Patch, click to expand. –
#134655
Jun 2, 2009 at 2:14pm

Cool patch!

To use different colors you’d need to set the message “strokeparam color” with your RGBA values, using a [swatch] or something. Just make the [pak] take a bigger list that can have the colors separated. I rearranged some things and exposed some of the parameters in this version:

– Pasted Max Patch, click to expand. –
#134656
Jun 3, 2009 at 12:13am

Hi seejayjames-

Thank you for responding to my question!!!
I have been working with your suggestion and am still coming up with funny results. I was able to get the swatch object to change the brightness of the trails but not the hue. I decided to make a very simple patch using the pack object, the color swatch and the strokeparam object found in the patch created by nesa. If you open this patch and look at the max window, the values coming out of the swatch are very different than the values coming out of the strokeparam color message. I have no idea what is causing this. Do you?

Thank you again for your response!
Lisa Marie

– Pasted Max Patch, click to expand. –
#134657

You must be logged in to reply to this topic.