Difficult one: Multiple screentoworld tracking

    May 01 2010 | 7:24 pm
    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?

    • May 02 2010 | 7:17 pm
      You could use several [jit.gl.handle] and [poly~] ?
    • May 03 2010 | 1:36 pm
      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.
    • May 03 2010 | 3:03 pm
      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?
    • May 03 2010 | 4:07 pm
      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?
    • May 03 2010 | 5:29 pm
      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!
    • May 03 2010 | 7:04 pm
      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.
    • May 04 2010 | 4:29 pm
      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.
    • May 05 2010 | 8:36 am
      The Jitter tutorial called something like "Jitter JavaScript with Window Callbacks" might help you out if you know JavaScript...
    • May 05 2010 | 7:22 pm
      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.
    • Nov 23 2011 | 7:48 pm
      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.
    • Apr 01 2014 | 4:22 pm
      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 :)
    • Apr 02 2014 | 3:32 am
      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/