I am working on a little augmented reality games in java. We decided to use the power of processing to speed up coding.
We use it as an independent library in order to make it transparent for the rest of the app. The input module (from a webcam or a video) works fine thanks to GSVideo.
We would like to have a class "render" which would be able to take an array pixels[], use a PApplet, PGraphics, OPENGL etc. to draw whatever we want on it, and then return the result in a pixels[] array.
I've tried several things, from some examples found on the web...here's an example of what I want to make work :
/* and then, how can I retrieve the modified image ?? */ context.loadPixels(); // ? context.updatePixels(); // ? return context.pixels; // ?
}
public PImage PixelsToPImage(int[] pix) { MemoryImageSource mis = new MemoryImageSource(width, height, pix, 0, width); Toolkit tk = Toolkit.getDefaultToolkit(); return new PImage(tk.createImage(mis)); }
public static void main() { // create a GraphRenderer object testMyOpenGLInProcessing g = new testMyOpenGLInProcessing(320, 240);
// have the GraphRenderer render out to a file; the file extension determines the output format int[] result = g.augment(...a_pixels_array...); // ... common scenario
.
.
. } }
Does someone has already used processing like this ? Every answer would be very useful !