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
whats wrong? (Read 630 times)
whats wrong?
Mar 29th, 2006, 10:02pm
 
hi,

can anyone help me to solve the problem!?

here is my code:

import processing.video.*;
Capture myCapture;


int xpos = 0;
int ypos = 0;
int w = 1280; // window width
//capturing video at 180x120 pixels
int vw = 180; // video width
int vh = 120; // video height
boolean newFrame = false;

   

void setup()
{
 size(w, vw*2);
 String s = "DV Video";
 myCapture = new Capture(this, s, vw, vh, 25);
}

void captureEvent(Capture myCapture) {
 myCapture.read();
}

void draw() {
 
 if(newFrame) {
   if(xpos > w) {
     xpos = 0;
     ypos += vw;
   }
   for (int y = 0; y < vw; y ++){
     set(xpos, y+ypos, new Capture[y+vw*(vh/2)]);
   }
   xpos += 1;

   if (xpos>w && ypos>1){ // save image
     String var = "shot_"+month()+"."+day()+"_"+hour()+"."+minute()+"."+second()+".tif";
     save(var);
   }
   newFrame = false;
 }
}

thx!

best,
pros.
Re: whats wrong?
Reply #1 - Apr 7th, 2006, 12:18am
 
A couple of things look a bit odd. For one there is no opportunity for newFrame to become true, the code in draw() will never be executed. You need to set newFrame to true in the captureEvent block.

Secondly set(xpos, y+ypos, new Capture[y+vw*(vh/2)]); seems to suggest you're accessing an array of capture objects and defining a new Capture object at the same time inside a function. Perhaps you wanted

set(xpos, y+ypos, myCapture);

or

image(xpos, y+ypos, myCapture);

Which would draw the capture image onto the screen. What it looks like you're doing is a Flash programmer mistake and thinking that objects must have a name[stringNumberAttachment] format. Whereas the square brackets in Processing generally only get used to point to an item in an array. If that was the case then I also would assume you're trying to make a movie clip instance as well, and there's no need for that. In Processing you're generally drawing to an array of pixels all the time so things don't need to be caught inside movie clips.

Hope this helps you.
Page Index Toggle Pages: 1