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 & HelpPrograms › Mask with Jmyron :(
Page Index Toggle Pages: 1
Mask with Jmyron ? :( (Read 457 times)
Mask with Jmyron ? :(
Feb 4th, 2008, 3:30pm
 
hi people,

i am trying to mask image by using Jmyron. it is working but too slow how can I solve it ? any suggestions?


//////////
import processing.opengl.*;
import JMyron.*;
JMyron m;
PImage[] frames;
PImage img,bg;
float[][] mask;
float decay = 0.016;
//--------------------
void setup(){
 size(320,240,OPENGL);
 m = new JMyron();
 m.start(width,height);
 m.findGlobs(1);
 m.adaptivity(50.0);
 frameRate(50);
 frames = new PImage[2];
 frames[0] = loadImage("car1.jpg");
 frames[1] = loadImage("car2.jpg");
 mask = new float[width][height];
}
//--------------------
void draw(){
 loadPixels();
 m.update();
 m.imageCopy(pixels);
 int[][] b = m.globBoxes();
 for(int i=0 ; i<width ; i++){
   for(int j=0 ; j<height ; j++){
     for(int c=0 ; c<b.length ; c++){
     float brush = brushPower(b[c][0] , b[c][1] ,i,j);
     mask[i][j] = constrain( mask[i][j] - decay + brush, 0 , 1 );
     //pixels[i+j*width] = getPixel(i,j);
    }
   }
   }
updatePixels();
}
//--------------------
float brushPower(int ox, int oy,int x, int y){
 float d = dist(ox,oy,x,y);
 return 0.09*exp(-d*d*0.00025);
}
//--------------------
color getPixel(int i, int j){
 float amount = mask[i][j];
 int index = i+j*width;
 if(amount<0.3333)
   return lerpColor(frames[0].pixels[index],frames[1].pixels[index],3*amount);
 else
   return lerpColor(frames[1].pixels[index],frames[1].pixels[index],2*amount-1);
}
Re: Mask with Jmyron ? :(
Reply #1 - Feb 5th, 2008, 8:47am
 
any idea?
Re: Mask with Jmyron ? :(
Reply #2 - Feb 24th, 2008, 9:01pm
 
is it now working better?

I might have the same problem,,dont know how to improve the debugging....


F/
Page Index Toggle Pages: 1