|
|
(3 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| ==Pixel Motion Detection -- File Input ==
| | Sein und Nichtsein, das ist immer die Antwort. |
|
| |
|
| <pre style="font=2">
| | == Idee == |
| import processing.video.*;
| |
| Movie cam;
| |
| PImage save, out;
| |
|
| |
|
| //// threshold for fine-tuning and artefacts
| |
| float thresh = 2;
| |
|
| |
|
| void setup() {
| |
|
| |
|
| | == Hintergrund == |
|
| |
|
| ///change to your footage path
| |
| cam = new Movie(this, "E:/vids/MVI_5018.MOV");
| |
|
| |
|
|
| |
|
| cam.loop();
| | == Skizze == |
| cam.jump(random(cam.duration()));
| |
| cam.volume(0);
| |
|
| |
|
| |
| // set windows size to match footage resolution
| |
| size(cam.width, cam.height);
| |
|
| |
|
| |
|
| ///setup previous frame and output-image
| |
| save = createImage(1280, 720, RGB);
| |
| out = createImage(1280, 720, RGB);
| |
| }
| |
|
| |
|
| void draw() {
| | [[Image:Af_bioart_tmp.png|700px]] |
|
| |
|
| loadPixels();
| |
| motiondetect();
| |
|
| |
|
| out.updatePixels();
| |
| image(out, 0, 0, width, height);
| |
|
| |
| }
| |
|
| |
|
|
| |
|
| void motiondetect() {
| |
|
| |
|
| cam.loadPixels();
| |
| save.loadPixels();
| |
|
| |
|
|
| |
|
| ///scann through input pixels
| |
| for (int x = 0; x < cam.width; x ++ ) {
| |
| for (int y = 0; y < cam.height; y ++ ) {
| |
| int loc = y*cam.width+x;
| |
| color c = cam.pixels[loc];
| |
| color c_l = save.pixels[loc];
| |
|
| |
|
| ///get colors of each pxl
| |
| float r = red(c);
| |
| float g = green(c);
| |
| float b = blue(c);
| |
| ///get colors of each pxl -> prev frame
| |
| float r_l = red(c_l);
| |
| float g_l = green(c_l);
| |
| float b_l = blue(c_l);
| |
|
| |
|
| ///compare
| |
| float dif = dist(r, g, b, r_l, g_l, b_l);
| |
|
| |
|
| ///exchange pxls to make change visible
| | == Misc == |
| if (dif>thresh) {
| |
| out.pixels[loc] = color (abs(r-r_l), abs(g-g_l), abs(b-b_l));
| |
| } else {
| |
| out.pixels[loc] = color (0);
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
|
| | | [http://www.uni-weimar.de/medien/wiki/images/Drops_evalnature_color_trails.zip sketch for visual juicing] |
| void movieEvent(Movie m) {
| | [[File:Af_drops_simple_trails.png|720px|thumb|left|trails]] |
| | | [[File:Af_drops_color_corr.png|560px|thumb|left|color correction]] |
| ///get cam image and copy as previous frame
| |
| if (m.available()) {
| |
| save = m.get();
| |
| save.updatePixels();
| |
| m.read();
| |
| }
| |
| }
| |
| | |
| | |
| | |
| | |
| | |
| </pre>
| |