Difficult one: Multiple screentoworld tracking

May 1, 2010 at 7:24pm

Difficult one: Multiple screentoworld tracking

I have just figured out how to use screentoworld

but… Here goes a more difficult question:
since each screentoworld message is carrying two variables, being sent to jit.gl.render and get the coordinates through route screentoworld.

So what if I have multiple, say 3, points on the screen which i want to get them “translated” how can I distinguish each of them? Is there any way other than copying jit.gl. render 3 times?

Thanks!

#50114
May 2, 2010 at 7:17pm

You could use several [jit.gl.handle] and [poly~] ?

#179926
May 3, 2010 at 1:36pm

I just use a receive connected to the jit.gl.render.
You can then grab any screentoworld / worldtoscreen anywhere in your patch, much like a normal function call.

#179927
May 3, 2010 at 3:03pm

Thanks! Kyred and Graaff!!

Graff, I tried the receive object but since the 3 points on screen are changing continuously. How can I get those points “translated” so that the jit.gl.sketch can redraw those points continuously?

#179928
May 3, 2010 at 4:07pm

Well, I suppose that since they’re moving all the time, you know where they are? I find it hard to understand exactly what you’re trying to do, as I don’t really see the need for screentoworld or 2d coords here. jit.gl.sketch works fine in 3d, right? This may help, if still stuck maybe you can post a patch?

– Pasted Max Patch, click to expand. –
#179929
May 3, 2010 at 5:29pm

Attached is my patch.

I have highlighted the problematic part, making the patch running extremely slow, since it drawn too much computational power. hopefully I illustrate the whole picture better.
But You will need cv.jit and a webcam to get it run.

Thanks so much for your help!

#179930
May 3, 2010 at 7:04pm

you’ve got several problems with the patch you posted.
i’m pretty sure you don’t want to have multiple gl.render’s with the same name (i didn’t even know that was possible).
you also need to make sure you understand the difference between “pack” and “pak” and when to use which.

here’s a basic example of drawing opengl shapes using the output of cv centroids.
notice the use of jit.submatrix, one way of many to limit the number of blobs that get drawn.

– Pasted Max Patch, click to expand. –
#179931
May 4, 2010 at 4:29pm

THANKS so much! robtherich!

it is basically what I want to do. But could you please explain the patch a bit more? I cannot get the logic how you can draw more than 1 circle with one screentoworld object in the patch.

Since I want to control the 3 edges of a triangle with say 3 coordinates on screen, how I can grab those openGL coordinates, feed them to the 3 edges?

Thank you very much.

#179932
May 5, 2010 at 8:36am

The Jitter tutorial called something like “Jitter JavaScript with Window Callbacks” might help you out if you know JavaScript…

#179933
May 5, 2010 at 7:22pm

it’s all about timing and ordering of messages.
in the patch i posted, we are using the matrix output of centroids, to trigger the draw calls to gl.render.
centroids is controlled by the output of qt.grab, in turn controlled by the metro. so we have one source of timing for all the activities in the patch.

the matrix from centroids gets sent to a trigger object (one of the most important objects to master in Max). as you should know from jitter tutorials, a matrix is simply a list of two symbols(“jit_matrix” followed by the matrix name).

the first thing we do when receiving a new matrix (or frame) is reset our gl.sketch, and tell our gl.render to erase. next, we send the matrix to a jit.iter, so we can use the values from that matrix to draw in our render context. as you can learn from the help file, jit.iter spits out a list for each cell in the matrix. the list contains that cell’s plane values. every time we receive a new list from jit.iter (ie for every cell in the matrix), we send the “screentoworld” message to gl.render. the very next event will be gl.render responding to the “screentoworld” message with the appropriate values.

we use these values to send draw messages to gl.sketch.
it is here that you can change what’s being drawn. you can use this list as the center of a triangle (you will have to do the necessary math to create the three vertices surrounding the center point), or the position attribute for a gl.gridshape, or whatever you wish.

once we’ve iterated all the cells in the matrix, and drawn them using whatever gl method desired, the trigger object sends a final bang to the gl.render context, telling it to draw everything to the window.

hope this helps.

#179934
Nov 23, 2011 at 7:48pm

What if you want to use the area data from the centroid blobs as the circle size? I can’t get that to work, I’m guessing because it throws off the timing of everything.

#179935
Apr 1, 2014 at 9:22am

Hi (anyone)…

I have similar problems – only rampant throughout my patch(es) – am new to gl objects and data flow sensibilities. I’ve mined the forums, spent countless hours w/ tut’s and experimental patches, to no avail…. And I suspect the underlaying ‘fixes’ are probably fundamental / simple but… I don’t understand most of what the GL reference patches offer (vocabulary-wise) so…. Help?

I am utilizing centroids blobs to produce ‘moveto’(a textured gl shape) / ‘position’ / ‘scale’ with no no no luck whatsover ;\ I believe a big part of the challenge is that I’m utilizing live feed video for dynamic coordinates as well as a source for gl.textures (which I’m still figuring out how to overlay or glue to gl shape).

But to provide a more simplified eg: I cannot pull data from the cv.jit.grab or it’s connected matrix (tried lcd, tried matrix conversion, tried pwindow renaming etc) for screentoworld purposes.

Basically: I am able to produce / calculate screentoworld data in some cases but not all. I am unable to send / recieve screentoworld coordinates at all nada nien.

Gl objects, throughout my patches (and in subpatches), do not respond to the usual send and recieve of trigger/list/bang from cv.jit.grab. So I’m think’n the problems, at base, are the matrix output type and the method of timing or syncing triggers… ?

I can post a patch, if need be, but am think’n it’ll confuse more than clarify :)

#285424
Apr 1, 2014 at 8:32pm

Put together a problem patch, to exemplify the above and other issues, and uploaded it here: http://cycling74.com/forums/topic/live-video-w-gl-textures-cv-jit-track-and-follow-attempt/

#285463

You must be logged in to reply to this topic.