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
Mysterious CPU usage (Read 856 times)
Mysterious CPU usage
May 25th, 2010, 12:14pm
 
I'm starting to experiment with using video capture from a built-in device, pretty much trying to build my own version of the ColorSorting example inside Processing (or here: http://processing.org/learning/libraries/colorsorting.html), but my sketch seems to be devouring my CPU to the point that it's unusable.

My code is below, and as you can see i'm only reading pixels from the webcam, not even drawing them, yet my sketch is too hard to run, whereas the ColorSorting example and other video examples that seem to do much more run fine.

Any ideas! I amaze myself with how quickly I am able to break a basic example! Cry
Code:
import processing.video.*;

Capture cam;

void setup() {
 size(320, 240, P2D);
 frameRate(10);

 cam = new Capture(this, 320, 240);
}


void draw() {
 if (cam.available() == true) {

   cam.read();
   cam.loadPixels();//load's new camera frame.
   
   for(int a=0; a<cam.width; a++){//loop through all horizontal pixels.
   
     for(int b=0; b<cam.height; b++){//loop through all vertical pixels.  
       
         println(a+" "+b);
   
   }//end of vertical pixels loop.
   
 }//end of horizontal pixels loop.
   
   delay(2000);
 
}//end of if video exists.
 
}//end of draw.

Page Index Toggle Pages: 1