Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
hooperstu
hooperstu's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
jMyron motion tracking and webcam background
[0 Replies]
05-Jul-2012 03:57 AM
Forum:
Contributed Library Questions
I want to track motion with jMyron to add some MSAFluid when things move. But I want the background to be a standard webcam output.
I was going to do this by placing a webcam feed over the top of the motion tracker, then layering the MSAFluid over the top of that.
Any ideas towards this would be great.
Currently it runs like this and looks terrible ..
import com.nootropic.processing.layers.*;
import JMyron.*;
JMyron onScreen;
int[] currFrame;
int[] prevFrame;
int tolerance;
boolean revealing;
AppletLayers layers;
void setup() {
size(640,480);
onScreen = new JMyron();
onScreen.start(width, height);
onScreen.findGlobs(0);
// initialize the pixel arrays to avoid a NullPointerException
loadPixels();
currFrame = prevFrame = pixels;
tolerance = 50;
revealing = true;
}
void draw()
{
// erase the previous image
onScreen.update();
// save the last frame before updating it
prevFrame = currFrame;
currFrame = onScreen.image();
// draw each pixel to the screen only if its change factor is
// higher than the tolerance value
loadPixels();
for (int i=0; i < width*height; i++)
{
if (comparePixels(i))
{
pixels[i] = currFrame[i];
}
}
updatePixels();
}
boolean comparePixels(int index)
{
if (Math.abs(red(currFrame[index])-red(prevFrame[index])) < tolerance)
if (Math.abs(green(currFrame[index])-green(prevFrame[index])) < tolerance)
if (Math.abs(blue(currFrame[index])-blue(prevFrame[index])) < tolerance)
return !revealing;
return revealing;
}
void keyReleased()
{
if (key == '.' || key == '>')
{
// increase tolerance
tolerance += 2;
println("Tolerance at " + tolerance);
}
else if (key == ',' || key == '<')
{
// decrease tolerance
tolerance -= 2;
println("Tolerance at " + tolerance);
// toggle the revealing mode
}
else if (key == ' ')
{
revealing = !revealing;
}
}
public void stop() {
onScreen.stop();
super.stop();
}
«Prev
Next »
Moderate user : hooperstu
Forum