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 & HelpVideo Capture,  Movie Playback,  Vision Libraries › Masking a Video Capture [JMyron] - very slow
Page Index Toggle Pages: 1
Masking a Video Capture [JMyron] - very slow (Read 1100 times)
Masking a Video Capture [JMyron] - very slow
Jul 7th, 2008, 2:20am
 
hello everyone

i 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
Re: Masking a Video Capture [JMyron] - very slow
Reply #1 - Jul 7th, 2008, 10:51am
 
try creating the graphics once in setup() instead of creating a new one at each frame in draw() :

Code:
webcammask=createGraphics(webcamwidth,webcamheight,P3D); // create mask 

Re: Masking a Video Capture [JMyron] - very slow
Reply #2 - Jul 7th, 2008, 12:07pm
 
im not sure but i think i makes a little difference in the speed.. thanks for the advice
Page Index Toggle Pages: 1