greg
YaBB Newbies
Offline
Posts: 5
Storing video into a 3D array
May 9th , 2005, 3:32am
Hello All, Inspired by Eddie Elliott's work at http://www.lightmoves.net/videostreamer/ I'm trying to store live video into a 3D array so that I can slice through it at different angles later. My code currently looks like this: ***************** import processing.video.*; Capture webCam; int vidW = 320; int vidH = 240; int winX = 640; int winY = 560; int fps = 30; int seconds = 5; int t = fps*seconds; int videocube[][][] = new int[t][vidW][vidH]; void setup() { size(winX, winY, P3D); background(0); println(Capture.list()); String captureDevice = "IIDC FireWire Video"; webCam = new Capture(this, captureDevice, vidW, vidH, fps); noStroke(); lights(); } void captureEvent(Capture webCam) { webCam.read(); } void draw() { translate(width/2, height/2); image(webCam, -vidW/2, -vidH/2); int row; int pix[] = webCam.pixels; color c; if (frameCount<t) { for(int y=0; y<vidH; y++) { row = y*vidW; for(int x=0; x<vidW; x++) { c = pix[row + x]; videocube[frameCount][x][y] = c; } } } if (frameCount>t) { rotateX(-PI/6); rotateY(PI/6); background(255); for (int j=0; j<t; j=j+10) { for (int k=0; k<vidW; k=k+10) { for (int l=0; l<vidH; l=l+10) { fill(red(videocube[j][k][l]), green(videocube[j][k][l]), blue(videocube[j][k][l])); box(k,l,j); } } } } } **************** I'm getting strange results that look nothing like the video coming from the webcam: http://gregorylindley.com/processing/videocube.png It's almost as if I'm stacking the frames and then cutting through them horizontally instead of perpendicularly. Any suggestions are greatly appreciated.