Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ウェブカメラに写る歩行者を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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.