GSVideo pixel extrusion
in
Contributed Library Questions
•
1 year ago
I've been working on a script that takes video and extrudes each pixel based on brightness or color values. I've gotten it to work using GSCapture and my webcam but I cant get it to work on a quicktime movie. i've incorporated the PeasyCam library to be able to orbit around and zoom into the pixel cloud. So, i'm not sure where to insert the mov.read() and loadPixels() commands --- in draw or movieEvent? will that matter? For GSCapture, it works in draw. running windows on macbook.
Does anyone see what im doing wrong here? i'd really like to get it going using a .mov file (GSVideo) rather than the webcam (GSCapture). Thanks!!
- import codeanticode.gsvideo.*;
- import peasy.*;
- //import processing.video.*;
- int cellsize = 2; // Dimensions of each cell in the grid
- int cols, rows; // Number of columns and rows in our system
- //Movie mov;
- //GSCapture mov; //unhide this to use the webcam and hide GSMovie below
- GSMovie mov;
- PeasyCam cam;
- void setup() {
- size(640, 480, P3D);
- //mov = new Movie(this, "animation 1.mov");
- mov = new GSMovie(this, "sponge animation.mov");
- //mov = new GSCapture(this, width, height); // unhide this and below for webcam. hide above too
- //mov.start();
- cols = mov.width/cellsize; // Calculate # of columns
- rows = mov.height/cellsize; // Calculate # of rows
- cam = new PeasyCam(this,mov.width/2,mov.height/2,0,1000);
- }
- void movieEvent(GSMovie m) {
- m.read();
- m.loadPixels();
- }
- void draw() {
- background(0);
- // mov.read();
- // mov.loadPixels();
- // Begin loop for columns
- for ( int i = 0; i < cols;i++) {
- // Begin loop for rows
- for ( int j = 0; j < rows;j++) {
- int x = i*cellsize + cellsize/2; // x position
- int y = j*cellsize + cellsize/2; // y position
- int loc = x + y*mov.width; // Pixel array location
- color c = mov.pixels[loc]; // Grab the color
- // Calculate a z position as a function of mouseX and pixel brightness
- float z = brightness((mov.pixels[loc]));
- // Translate to the location, set fill and stroke, and draw the rect
- //if (z > 200) {
- // z = 200;
- //}
- pushMatrix();
- translate(x,y,z);
- fill(c);
- noStroke();
- rectMode(CENTER);
- //if (brightness(c) > 4) {
- rect(0,0,cellsize,cellsize);
- // }
- popMatrix();
- //mov.updatePixels();
- }
- }
- }
- //void keyPressed() {
- // saveFrame();
- //}
:
1