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?
You could use several [jit.gl.handle] and [poly~] ?
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.
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?
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. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1226.3oc2YtsjZaCFG+Z3oPC2jYZITK4y8p1K6yPmLYD1BPIFIWYQX2jIu6U GryR1XvJfQE2gcsvGv9S+ze8cP9KymsXM+IRyBvuC9avrYeY9rYlCoOvr18m sXO9ohJbi4xVTv2umvjKVZOmj7jzbb5a1CXbI3PCksEH2Q.ghRvmvUGHKAT4 aZ.M78DvZ91CMfRRsb25Ca1PD.o.yZpvRJmYubvwczhcf+BTxM2wi3WdbUTF ofefYdlgsGrFKK1odpuWPJj19RbR9pfk.XbnoIEpahTaAuq8GQKMlMe8GdaX 2ceCmIY38DyY9SAEWc5YZne1bFXf5lYOL6vdJqhHMnA1YNBRihPldzolTlwH fIFSJncy2rG0sheP1cuBzG7qymq2r7FGYdle.TfYZbJ2Qa.X1yG2QDpgEbCn hqFsTs5KZG9SDPAmKJa.7MlwPEdzcf9nO57zOJHU28hQ1NroAkeF3mOtz+14 HibTYX+.FeK.Er3BJNTlo2laZBQqhU6jcRe1ZUxmqI1evBpli8QjzwgHndIB zaDIJezHRxDgH+5.Zjb3XQD3+SHRb9XQjfI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_max5_patcher-----------
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!
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. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1776.3oc0at0bahCE.94jeEZ7zGS8HID21oOj76Xmc5.XEaZAjW.2jc6z+6q tQJNwt93X33tsSSBXh3nOctK0ue6MKxUOK6VP9CxeRt4lue6M2Xuk4F23u9l E0YOWTk0YerEEp5ZYS+h6beVu74d68+zG+HQ01uQstMa6lxBx1V0WjE8kpFh rIKuRtZ32oYWcYSkr2NfL+MKWYGFU9W9X.e3IeT0z2jUKsezCskYUCex1VYm VLxLi+ma0uG2bPvDKo2QBoQluQ8eg7W+7Mq10O7poCiUVewlxl0iGGZncbX1 gfysCGe7PYDstx+0JZL9Rp4t+31aMe4tI.kOU1rR8Dw7FHcxdRuhrprlndjn 4aNoNqus7Yv.kdZfBFMgBKShhCuRnoprtTCjMRhVlyksFnjWox6fhCdxDhCQ fiCNMEVDcNvgahBd9IN24G2eW2s5+msR2jaQoYMfrHOqY8hWlPGfBAozQTHb VfPsrqKas7M5DF6hOvNHb3G.NryENriAGPDQLhHrjIVsP9jdJ8Ff7kx9kc6x c9HH2a3S.TcGV5jo6nEiOO3m5Dvhm3LhhcXhkho9SQYaQkTGm.rNDKFIcn.m qVpSGJcNzgNFUpUeSpC57AF4CbBELYDnZc4ICiho4UOImTA1dhOY1SVmvmxR JvE.JL1ymYIZzwc6rtZY2WkZohzK65ACI1jAoSCHg0USj6adMGjHTqVb0oyU zJ041ndR0VANmXFEQD40gDduwQHhndhIw9dhr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idHyN6L5g1TtZkrYbQd0 kq1pz1xdg3HKEPkoW85NrLIvUjLoJ96Fm3B.xzqVfmaYBhHEedRDOUX1hO+4 W0aPr+UhDmaP2SZu5BmGlUR1zNOBo7AoKbOYM7Bk0X.xp4H+gnZP3zqFboVv PzLY3Zrvh+8SlR+8SjLqb7SHRHGghCgRw3KSmzM.1gMgvINpxTD.LEt2yfgD QAHQ3wHHI6DgtDAYUiipWoSZtgq0FfUs.bCl.w9OM.UqMXoxmhqAWBnvtTjW 8f.pDbi7lFCUiBQYBhgWJtQ4RgjghoAVX5eBVZSrPjkJXUFDgrTAw3iyQVnf jpB+LIEm5JHNv1Xyjedwk1dD9LHrLNaVD1Wq0OQnMYdjVNH8.bq+4UNylF.h AmRwkSogfb2grPIlgvUliYo4+a.tSmqS62dwkJrQygvFFNOBaxLHrb57PVFC V6mvNrGLoR7tbNy78t1EEjMA8tFp7FbIxqOP3THuofKH6LpRzoTJnhQGl3Wc kvui4T6SJt7vhvbsdQ6Hi9heb6+wlVm09 -----------end_max5_patcher-----------
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.
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.
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.
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 :)
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/
Forums > Jitter