This is working:
Code:
import processing.video.*;
Capture myCapture1;
void setup() {
size(800, 600, P3D);
fill(0, 153);
noStroke();
myCapture1 = new Capture(this, 320, 240, 24);
}
void draw() {
background(255);
myCapture1.read();
image(myCapture1, 0, 0);
translate(width/2, height/2);
rect(-200, -200, 400, 400);
}
this isn't:
Code:
import processing.opengl.*;
import processing.video.*;
Capture myCapture1;
void setup() {
size(800, 600, OPENGL);
fill(0, 153);
noStroke();
myCapture1 = new Capture(this, 320, 240, 24);
}
void draw() {
background(255);
myCapture1.read();
image(myCapture1, 0, 0);
translate(width/2, height/2);
rect(-200, -200, 400, 400);
}
Why? What would be the solution if I wanted to use OpenGL as render, when there are data in the sketch that are retrieved from webcamera?
Actually I don't even need to "show" video on the screen, just to do math from webcamera data, i.e.,
Code:
import processing.opengl.*;
import processing.video.*;
Capture myCapture1;
void setup() {
size(800, 600, OPENGL);
fill(0, 153);
noStroke();
myCapture1 = new Capture(this, 320, 240, 24);
}
void draw() {
background(255);
myCapture1.read();
myCapture1.loadPixels();
do some maths based on myCapture1.pixels[] values
translate(width/2, height/2);
rect(drawn based on myCapture1.pixels[] values);
}
Thanks in advance,
kroko