Created
July 10, 2014 16:03
-
-
Save taroyabuki/5000a995b2a6e3e37985 to your computer and use it in GitHub Desktop.
ウェブカメラに写る歩行者をProcessingで消す方法 http://blog.unfindable.net/archives/7642
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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