Skip to content

Instantly share code, notes, and snippets.

@taroyabuki
Created July 10, 2014 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taroyabuki/5000a995b2a6e3e37985 to your computer and use it in GitHub Desktop.
Save taroyabuki/5000a995b2a6e3e37985 to your computer and use it in GitHub Desktop.
ウェブカメラに写る歩行者をProcessingで消す方法 http://blog.unfindable.net/archives/7642
import processing.video.*;
Capture capture;
int t = 0;
int mask = (1 << 8) - 1;
void setup() {
size(640, 480);
background(0);
capture = new Capture(this, 640, 480);
capture.start();
}
void draw() {
if (mousePressed) {
t = 0;
}
if (capture.available() == true) {
capture.read();
loadPixels();
for (int i = 0; i < width * height; ++i) {
//pixels[i] = cam.pixels[i];
color accum = pixels[i];
color now = capture.pixels[i];
int b = ((accum & mask) * t + (now & mask)) / (t + 1);
int g = (((accum >> 8) & mask) * t + ((now >> 8) & mask)) / (t + 1);
int r = (((accum >> 16) & mask) * t + ((now >> 16) & mask)) / (t + 1);
pixels[i] = color(r, g, b);
}
++t;
updatePixels();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment