drawing a texture from jit.matrix data

Jacob's icon

Hello,

I'm interested in drawing a gl texture using the binary edge pixels (the outlines) of live jit.grab video feed that have been isolated from the rest of the video image by having gone through a cv.jit.binedge object.

basically I am interested in transitioning a lot of gl static (generated by jit.noise and the "points" drawing primitive going into a gl.render similar to the one in Jit Tutorial 37) into the outline of a live video image.

Can I do this? (especially if the live feed is constantly changing) How to I translate the jit.matrix info into vertex point data? Do I need to put it into java as in the jit tutorial 40 (which only does a few fixed vertex points at a time)?

Or am I going about this effect all wrong?

Thank you!
J

Rob Ramirez's icon

easiest way to draw arbitrary matrix data as vertices might be jit.gl.mesh @drawmode polygon. first dimension is the number of vertices in each polygon and second dimension is the number of polygons drawn.

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

Jacob's icon

Thanks for the reply and sample patch.

I am still a bit confused and was wondering if I could ask you about the patch you sent (keep in mind, I'm a relative beginner to both jit.gl and cv.jit).

I see that you are building shapes through the expr's and op's and drawing them into the gl.mesh, but I am confused where the vector point info is put into the drawing/render context from the equations for the shapes. I'm also not sure how I would be able to import specific vector points into this context.

Jean Mark Pelletier's external cv.jit.binedge object, which finds the edges of objects in an image or video stream (I'm actually using the cv.jit.canny object which does the same thing but works a little better), exports a 1-plane char jit.matrix where the main edge of an object in the video stream or still image is a white outline over a black background.

If I hook up a jit.print to this matrix and bang it, it shows me the 1 plane value of each pixel, either 255 for the white outline, or 0 for the black background.

I would like to somehow mark the position of each 255 (white outline) pixel and import these pixels as vector points in a gl.mesh, gl.sketch, or any other gl object that will allow me to specify vector points and have them drawn using a "points" primitive, so they appear as points, not connected lines or polygons.

What I want to do is transition between video static (jit.noise) and points that form the shape of an outline of a live video feed. I am really interested in the effect of controlling, or seeming to control, the particles of random visual noise/static and have them organize around the outline of an image.

As I mentioned earlier, I really like the transition between visualized gl noise (random vertex points) and a gl.shape (very structured vertex points) in Jit Tutorial 37 and think it is close to the effect I am imagining. I just would like to switch the gl.shape, with vertices that form the simple outline of a live video image (like something from cv.jit.canny).

I figured that since I have a point A (visualized noise similar to Tutorial 37) and a point B (live edge detection from cv.jit.canny) that somehow transitioning between the two would be the way to go. Though I realize I may be wrong about this, and that there might be (and probably is) a much easier way to get the effect I am going for, and I am happy to try any other method you suggest.

Thanks so much for your time!!!
Jacob