Anyway, here's a fun little video experiment i knocked together in processing yesterday. You can copy and paste the code below into a sketch and run it, should be that simple. Ohhh yes, you'll also need GSVideo, as I'm not using processing 1.5's native video. After reading a few pages on what was required to get it working based on software that may or may not really exist anymore and also reading somewhere that p2 was going to move to GSVideo anyway, figured i might as well take the plunge. It's a pretty friendly library overall...on the subject of laziness, gotta admit i probably could've captured a video of this, but didn't. That's probably ok though, you should really run this yourself and see the effect, maybe play around with it a bit, see what you come up with...
import codeanticode.gsvideo.*; PVector gridStep = new PVector(16,8); int gridX; int gridY; GSCapture vStream; void setup() { size(640, 480, P2D); frameRate(30); gridX = int(width / gridStep.x); gridY = int(height / gridStep.y); vStream = new GSCapture(this, width, height); vStream.start(); background(0); noStroke(); } void draw() { if(vStream.available()) { vStream.read(); vStream.loadPixels(); //Thanks, RoHS fill(0,0,0,8); rectMode(CORNER); rect(0,0,width,height); for (int i = 0; i < gridX; i++) { for (int j = 0; j < gridY; j++) { int x = i*int(gridStep.x); int y = j*int(gridStep.y); int loc = (vStream.width - x - 1) + y*vStream.width; color col = color(red(vStream.pixels[loc]),green(vStream.pixels[loc]), blue(vStream.pixels[loc]), 32); float vradius = brightness(col)*0.1; fill(col); if(vradius<12.8) { ellipseMode(CENTER); ellipse(x, y, vradius,vradius); } else { rectMode(CENTER); rect(x,y,vradius,vradius); } } } } }
No comments:
Post a Comment