Hello every one,
I’am trying to split a vidéo image from a webcam onto 4 different textures. It works BUT i don’t understand why the original image from the webcam slow down or stop…
is my approach ok ? What did i missed ?
This is only a test. I’am going to split webcam image onto multiples vertex shape… so i want to use the good approach.
Thank you for your help.
import processing.video.*;
Capture cam;
PImage myTextureA, myTextureB, myTextureC, myTextureD;
void setup() {
size(500, 400, P3D);
String[] cameras = Capture.list();
if (cameras.length == 0)
{
println("There are no cameras available for capture.");
exit();
} else
{
println("Available cameras:");
for (int i = 0; i < cameras.length; i++)
{
println(cameras[i]);
}
cam = new Capture(this, 200, 200, cameras[0]);//0
cam.start();
}
myTextureA = new PImage(100, 100);
myTextureB = new PImage(100, 100);
myTextureC = new PImage(100, 100);
myTextureD = new PImage(100, 100);
}
void captureEvent(Capture video) {
video.read();
}
void draw() {
textureMode(NORMAL);
myTextureA.copy(cam, 0, 0, 100, 100, 0, 0, 100, 100);
myTextureB.copy(cam, 100, 0, 100, 100, 0, 0, 100, 100);
myTextureC.copy(cam, 100, 100, 100, 100, 0, 0, 100, 100);
myTextureD.copy(cam, 0, 100, 100, 100, 0, 0, 100, 100);
//display original webcam image
tint(255, 120, 120);
image(cam, 0, 0, 100, 100);
noTint();
//spliting the original webcam image onto 4 textures
/////////////
////A - B////
////D - C////
/////////////
//shape A
beginShape();
texture(myTextureA);
vertex(100, 0, 0, 0, 0);
vertex(300, 0, 0, 1, 0);
vertex(300, 200, 0, 1, 1);
vertex(100, 200, 0, 0, 1);
endShape();
//shape B
beginShape();
texture(myTextureB);
vertex(300, 0, 0, 0, 0);
vertex(500, 0, 0, 1, 0);
vertex(500, 200, 0, 1, 1);
vertex(300, 200, 0, 0, 1);
endShape();
//shape C
beginShape();
texture(myTextureC);
vertex(300, 200, 0, 0, 0);
vertex(500, 200, 0, 1, 0);
vertex(500, 400, 0, 1, 1);
vertex(300, 400, 0, 0, 1);
endShape();
//shape D
beginShape();
texture(myTextureD);
vertex(100, 200, 0, 0, 0);
vertex(300, 200, 0, 1, 0);
vertex(300, 400, 0, 1, 1);
vertex(100, 400, 0, 0, 1);
endShape();
}