hello everyonei wrote a code to mask a JMyron video-capture.
the mask -a PGraphics-Object- follows the mouse position.
the script is running very slow. i found a similar problem at
this topic but i couldn´t find a solution there. any ideas how to improve the speed of this script
greets iason Code:
import JMyron.*;
JMyron webcam;
PImage webcamimage;
PGraphics webcammask;
int webcamwidth = 320; int webcamheight = 240; // Webcam Resolution
int framerate = 25;
void setup() {
frameRate(framerate);
size(webcamwidth,webcamheight,P3D);
webcam = new JMyron(); //make a new instance of the object
webcam.start(webcamwidth,webcamheight); //start a capture
webcam.findGlobs(0); //disable the intelligence to speed up frame rate
webcamimage = createImage(webcamwidth,webcamheight,ARGB);
}
void draw() {
background(255);
webcam.update();
arraycopy(webcam.cameraImage(),webcamimage.pixels);
webcamimage.updatePixels();
float webcammasksize = random(webcamwidth/5,webcamwidth/3);
webcammask=createGraphics(webcamwidth,webcamheight,P3D); // create mask
webcammask.beginDraw();
webcammask.background(0);
webcammask.fill(255);
webcammask.ellipse(mouseX,mouseY,webcammasksize,webcammasksize);
webcammask.filter(BLUR,4);
webcammask.endDraw();
webcamimage.mask(webcammask); // apply mask to webcam image
image (webcamimage,0,0); // draw the masked image
}
public void stop(){webcam.stop(); super.stop();}//stop the camera object