Pixels + Live Video


The pixels from the video source are drawn as rectangles with size based on brightness, creating an abstract mirror visualization.

videoScale = 20; sets the distance between pixels, to be displayed as rows and columns using nested for loops. (int i = 0; i < cols; i++) calls all the columns and (int j = rows/2; j < rows/2+1; j++) calls only the row in the middle section of the screen. Later, each pixel location is used to display a rectangle whose size and color changes over time according to the brightness of the video source.

Processing code: import processing.video.*; int videoScale = 20; // Space used by each bar int cols, rows; Capture video; void setup() { size(960, 480); cols = width / videoScale; rows = height / videoScale; video = new Capture(this, cols, rows); video.start(); } void captureEvent(Capture video) { video.read(); } void draw() { background(#d6432e); video.loadPixels(); for (int i = 0; i < cols; i++) { for (int j = rows/2; j < rows/2+1; j++) { int x = i * videoScale; int y = j * videoScale; int loc = (video.width - i - 1) + j*video.width; color c = video.pixels[loc]; float sz = (brightness(c)/255)*videoScale; rectMode(CENTER); fill(255, sz*15); noStroke(); rect(x+videoScale/2, y+videoScale/2, sz/2, sz*15); } } }

Leave a Reply