We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › OpenGL and Capture. Solution
Page Index Toggle Pages: 1
OpenGL and Capture. Solution? (Read 485 times)
OpenGL and Capture. Solution?
Dec 18th, 2008, 10:50pm
 
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
Re: OpenGL and Capture. Solution?
Reply #1 - Dec 18th, 2008, 11:53pm
 
mkay, solved using JMyron

Code:

import processing.opengl.*;
import JMyron.*;

JMyron bCapture;
PImage aCapture;

int h = 320;
int w = 240;

void setup() {
size(800, 600, OPENGL);
fill(0, 153);
noStroke();
bCapture = new JMyron();
bCapture.start(h, w);
bCapture.findGlobs(0);
aCapture = new PImage(h, w);
frameRate(30);
}

void draw() {
background(255);
bCapture.update();
aCapture.loadPixels();
bCapture.imageCopy(aCapture.pixels);
aCapture.updatePixels();
image(aCapture, 0, 0);
translate(width/2, height/2);
rect(-200, -200, 400, 400);
}

public void stop(){
bCapture.stop();
super.stop();
}
Page Index Toggle Pages: 1