We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Storing video into a 3D array (Read 1504 times)
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.

Page Index Toggle Pages: 1